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/select_generator.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/select_generator.cc')
-rw-r--r-- | compiler/optimizing/select_generator.cc | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/compiler/optimizing/select_generator.cc b/compiler/optimizing/select_generator.cc index 54eac54c01..07065efbb7 100644 --- a/compiler/optimizing/select_generator.cc +++ b/compiler/optimizing/select_generator.cc @@ -46,9 +46,7 @@ static bool IsSimpleBlock(HBasicBlock* block) { } else if (instruction->CanBeMoved() && !instruction->HasSideEffects() && !instruction->CanThrow()) { - if (instruction->IsSelect() && - // TODO: Remove "OrNull". - instruction->AsSelectOrNull()->GetCondition()->GetBlock() == block) { + if (instruction->IsSelect() && instruction->AsSelect()->GetCondition()->GetBlock() == block) { // Count one HCondition and HSelect in the same block as a single instruction. // This enables finding nested selects. continue; @@ -77,8 +75,7 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) { HPhi* select_phi = nullptr; for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); if (select_phi == nullptr) { // First phi found. select_phi = phi; @@ -93,8 +90,7 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) { bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( HBasicBlock* block, ScopedArenaSafeMap<HInstruction*, HSelect*>* cache) { DCHECK(block->GetLastInstruction()->IsIf()); - // TODO: Remove "OrNull". - HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instruction = block->GetLastInstruction()->AsIf(); HBasicBlock* true_block = if_instruction->IfTrueSuccessor(); HBasicBlock* false_block = if_instruction->IfFalseSuccessor(); DCHECK_NE(true_block, false_block); @@ -220,8 +216,7 @@ bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) { DCHECK(block->GetLastInstruction()->IsIf()); - // TODO: Remove "OrNull". - HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instruction = block->GetLastInstruction()->AsIf(); HBasicBlock* true_block = if_instruction->IfTrueSuccessor(); HBasicBlock* false_block = if_instruction->IfFalseSuccessor(); DCHECK_NE(true_block, false_block); @@ -236,8 +231,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) // The innner if branch has to be a block with just a comparison and an if. if (!inner_if_block->EndsWithIf() || - // TODO: Remove "OrNull". - inner_if_block->GetLastInstruction()->AsIfOrNull()->InputAt(0) != + inner_if_block->GetLastInstruction()->AsIf()->InputAt(0) != inner_if_block->GetFirstInstruction() || inner_if_block->GetLastInstruction()->GetPrevious() != inner_if_block->GetFirstInstruction() || @@ -245,8 +239,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) return nullptr; } - // TODO: Remove "OrNull". - HIf* inner_if_instruction = inner_if_block->GetLastInstruction()->AsIfOrNull(); + HIf* inner_if_instruction = inner_if_block->GetLastInstruction()->AsIf(); HBasicBlock* inner_if_true_block = inner_if_instruction->IfTrueSuccessor(); HBasicBlock* inner_if_false_block = inner_if_instruction->IfFalseSuccessor(); if (!inner_if_true_block->IsSingleGoto() || !inner_if_false_block->IsSingleGoto()) { @@ -269,8 +262,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) return nullptr; } - // TODO: Remove "OrNull". - HPhi* first_phi = first_merge->GetFirstPhi()->AsPhiOrNull(); + HPhi* first_phi = first_merge->GetFirstPhi()->AsPhi(); // Second merge is first_merge and the remainder branch merging. It must be phi + goto, or phi + // return. Depending on the first merge, we define the second merge. @@ -292,8 +284,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) } size_t index = second_merge->GetPredecessorIndexOf(merges_into_second_merge); - // TODO: Remove "OrNull". - HPhi* second_phi = second_merge->GetFirstPhi()->AsPhiOrNull(); + HPhi* second_phi = second_merge->GetFirstPhi()->AsPhi(); // Merge the phis. first_phi->AddInput(second_phi->InputAt(index)); |