summaryrefslogtreecommitdiff
path: root/compiler/optimizing/dead_code_elimination.h
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2023-10-16 15:11:18 +0100
committer Santiago Aboy Solanes <solanes@google.com> 2023-10-31 12:00:37 +0000
commitfb1ccc8a5156ca248e726519d85a4d66f0ec70bc (patch)
tree23f9425ba627190187c45234dc33f056d68ce4cf /compiler/optimizing/dead_code_elimination.h
parente39c8bad3add22e01edefe4205d405a0bdc1c7ee (diff)
Remove empty ifs
If we had an HIf where both branches were empty, we wouldn't emit any code generation for the HIf. However, this still emits other instructions e.g. outer ifs, instructions used in the if guard. This CL detects when an HIf is empty and can be eliminated during DCE. Bug: 305225992 Fixes: 305225992 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: I81ff5ee1326b6a27480b1af88d41955f1ca2b823
Diffstat (limited to 'compiler/optimizing/dead_code_elimination.h')
-rw-r--r--compiler/optimizing/dead_code_elimination.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/optimizing/dead_code_elimination.h b/compiler/optimizing/dead_code_elimination.h
index ddd01f7103..789962f93c 100644
--- a/compiler/optimizing/dead_code_elimination.h
+++ b/compiler/optimizing/dead_code_elimination.h
@@ -40,6 +40,17 @@ class HDeadCodeElimination : public HOptimization {
private:
void MaybeRecordDeadBlock(HBasicBlock* block);
void MaybeRecordSimplifyIf();
+ // Detects and remove ifs that are empty e.g. it turns
+ // 1
+ // / \
+ // 2 3
+ // \ /
+ // 4
+ // where 2 and 3 are single goto blocks and 4 doesn't contain a Phi into:
+ // 1
+ // |
+ // 4
+ bool RemoveEmptyIfs();
// If `force_recomputation` is true, we will recompute the dominance information even when we
// didn't delete any blocks. `force_loop_recomputation` is similar but it also forces the loop
// information recomputation.