summaryrefslogtreecommitdiff
path: root/compiler/optimizing/dead_code_elimination.cc
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2022-12-16 19:28:47 +0000
committer Santiago Aboy Solanes <solanes@google.com> 2023-01-13 16:19:02 +0000
commit74da668328e1c501742a864d23ba8c114ece5e64 (patch)
treea8e6d643230ff9bec8ae8878cd8d1021b813a3e5 /compiler/optimizing/dead_code_elimination.cc
parent1f3861de4cacb51eacbb624e377b9dc7d7f96cc1 (diff)
Update the graph flags and check consistency
Check that the flags are up to date in graph checker. Mainly a correctness check CL but it brings slight code size reduction (e.g. not needing vreg info if HasMonitorOperations is false). Update loop_optimization_test to stop using `LocalRun` directly as it meant that it was breaking assumptions (i.e. top_loop_ was nullptr when it was expected to have a value). Bug: 264278131 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I29765b3be46d4bd7c91ea9c80f7565a3c88fae2e
Diffstat (limited to 'compiler/optimizing/dead_code_elimination.cc')
-rw-r--r--compiler/optimizing/dead_code_elimination.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc
index e15e731fcd..0ce8bfafae 100644
--- a/compiler/optimizing/dead_code_elimination.cc
+++ b/compiler/optimizing/dead_code_elimination.cc
@@ -629,7 +629,6 @@ bool HDeadCodeElimination::RemoveUnneededTries() {
}
}
- const size_t total_tries = tries.size();
size_t removed_tries = 0;
bool any_block_in_loop = false;
@@ -641,10 +640,6 @@ bool HDeadCodeElimination::RemoveUnneededTries() {
}
}
- if (removed_tries == total_tries) {
- graph_->SetHasTryCatch(false);
- }
-
if (removed_tries != 0) {
// We want to:
// 1) Update the dominance information
@@ -741,6 +736,33 @@ void HDeadCodeElimination::RemoveDeadInstructions() {
}
}
+void HDeadCodeElimination::UpdateGraphFlags() {
+ bool has_monitor_operations = false;
+ bool has_simd = false;
+ bool has_bounds_checks = false;
+ bool has_always_throwing_invokes = false;
+
+ for (HBasicBlock* block : graph_->GetReversePostOrder()) {
+ for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
+ HInstruction* instruction = it.Current();
+ if (instruction->IsMonitorOperation()) {
+ has_monitor_operations = true;
+ } else if (instruction->IsVecOperation()) {
+ has_simd = true;
+ } else if (instruction->IsBoundsCheck()) {
+ has_bounds_checks = true;
+ } else if (instruction->IsInvoke() && instruction->AsInvoke()->AlwaysThrows()) {
+ has_always_throwing_invokes = true;
+ }
+ }
+ }
+
+ graph_->SetHasMonitorOperations(has_monitor_operations);
+ graph_->SetHasSIMD(has_simd);
+ graph_->SetHasBoundsChecks(has_bounds_checks);
+ graph_->SetHasAlwaysThrowingInvokes(has_always_throwing_invokes);
+}
+
bool HDeadCodeElimination::Run() {
// Do not eliminate dead blocks if the graph has irreducible loops. We could
// support it, but that would require changes in our loop representation to handle
@@ -764,6 +786,7 @@ bool HDeadCodeElimination::Run() {
}
SsaRedundantPhiElimination(graph_).Run();
RemoveDeadInstructions();
+ UpdateGraphFlags();
return true;
}