diff options
author | 2023-04-25 16:40:06 +0000 | |
---|---|---|
committer | 2023-04-27 10:53:55 +0000 | |
commit | cde6497d286337de2ed21c71c85157e2745b742b (patch) | |
tree | 087d790efb6987f5aab1da7cd91b89bedcdc5725 /compiler/optimizing/ssa_phi_elimination.cc | |
parent | 79dc217688a774fc532584f6551a0aec8b45bc4a (diff) |
Optimizing: Add `HInstruction::As##type()`.
After the old implementation was renamed in
https://android-review.googlesource.com/2526708 ,
we introduce a new function with the old name but new
behavior, just `DCHECK()`-ing the instruction kind before
casting down the pointer. We change appropriate calls from
`As##type##OrNull()` to `As##type()` to avoid unncessary
run-time checks and reduce the size of libart-compiler.so.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 181943478
Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e
Diffstat (limited to 'compiler/optimizing/ssa_phi_elimination.cc')
-rw-r--r-- | compiler/optimizing/ssa_phi_elimination.cc | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/compiler/optimizing/ssa_phi_elimination.cc b/compiler/optimizing/ssa_phi_elimination.cc index 2a1697d7a2..1d9be3956a 100644 --- a/compiler/optimizing/ssa_phi_elimination.cc +++ b/compiler/optimizing/ssa_phi_elimination.cc @@ -45,8 +45,7 @@ void SsaDeadPhiElimination::MarkDeadPhis() { // Add to the worklist phis referenced by non-phi instructions. for (HBasicBlock* block : graph_->GetReversePostOrder()) { for (HInstructionIterator inst_it(block->GetPhis()); !inst_it.Done(); inst_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = inst_it.Current()->AsPhiOrNull(); + HPhi* phi = inst_it.Current()->AsPhi(); if (phi->IsDead()) { continue; } @@ -98,8 +97,7 @@ void SsaDeadPhiElimination::EliminateDeadPhis() { HInstruction* next = nullptr; HPhi* phi; while (current != nullptr) { - // TODO: Remove "OrNull". - phi = current->AsPhiOrNull(); + phi = current->AsPhi(); next = current->GetNext(); if (phi->IsDead()) { // Make sure the phi is only used by other dead phis. @@ -107,8 +105,7 @@ void SsaDeadPhiElimination::EliminateDeadPhis() { for (const HUseListNode<HInstruction*>& use : phi->GetUses()) { HInstruction* user = use.GetUser(); DCHECK(user->IsLoopHeaderPhi()); - // TODO: Remove "OrNull". - DCHECK(user->AsPhiOrNull()->IsDead()); + DCHECK(user->AsPhi()->IsDead()); } } // Remove the phi from use lists of its inputs. @@ -138,8 +135,7 @@ bool SsaRedundantPhiElimination::Run() { // neither will necessarily converge faster. for (HBasicBlock* block : graph_->GetReversePostOrder()) { for (HInstructionIterator inst_it(block->GetPhis()); !inst_it.Done(); inst_it.Advance()) { - // TODO: Remove "OrNull". - worklist.push_back(inst_it.Current()->AsPhiOrNull()); + worklist.push_back(inst_it.Current()->AsPhi()); } } @@ -201,11 +197,9 @@ bool SsaRedundantPhiElimination::Run() { continue; } else if (input->IsPhi()) { if (!visited_phis_in_cycle.IsBitSet(input->GetId())) { - // TODO: Remove "OrNull". - cycle_worklist.push_back(input->AsPhiOrNull()); + cycle_worklist.push_back(input->AsPhi()); visited_phis_in_cycle.SetBit(input->GetId()); - // TODO: Remove "OrNull". - catch_phi_in_cycle |= input->AsPhiOrNull()->IsCatchPhi(); + catch_phi_in_cycle |= input->AsPhi()->IsCatchPhi(); irreducible_loop_phi_in_cycle |= input->IsIrreducibleLoopHeaderPhi(); } else { // Already visited, nothing to do. @@ -254,8 +248,7 @@ bool SsaRedundantPhiElimination::Run() { for (const HUseListNode<HInstruction*>& use : current->GetUses()) { HInstruction* user = use.GetUser(); if (user->IsPhi() && !visited_phis_in_cycle.IsBitSet(user->GetId())) { - // TODO: Remove "OrNull". - worklist.push_back(user->AsPhiOrNull()); + worklist.push_back(user->AsPhi()); } } DCHECK(candidate->StrictlyDominates(current)); |