From cde6497d286337de2ed21c71c85157e2745b742b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 25 Apr 2023 16:40:06 +0000 Subject: 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 --- compiler/optimizing/nodes_shared.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'compiler/optimizing/nodes_shared.cc') diff --git a/compiler/optimizing/nodes_shared.cc b/compiler/optimizing/nodes_shared.cc index 6216da8234..b3a7ad9a05 100644 --- a/compiler/optimizing/nodes_shared.cc +++ b/compiler/optimizing/nodes_shared.cc @@ -33,22 +33,17 @@ void HDataProcWithShifterOp::GetOpInfoFromInstruction(HInstruction* instruction, DCHECK(CanFitInShifterOperand(instruction)); if (instruction->IsShl()) { *op_kind = kLSL; - // TODO: Remove "OrNull". - *shift_amount = instruction->AsShlOrNull()->GetRight()->AsIntConstantOrNull()->GetValue(); + *shift_amount = instruction->AsShl()->GetRight()->AsIntConstant()->GetValue(); } else if (instruction->IsShr()) { *op_kind = kASR; - // TODO: Remove "OrNull". - *shift_amount = instruction->AsShrOrNull()->GetRight()->AsIntConstantOrNull()->GetValue(); + *shift_amount = instruction->AsShr()->GetRight()->AsIntConstant()->GetValue(); } else if (instruction->IsUShr()) { *op_kind = kLSR; - // TODO: Remove "OrNull". - *shift_amount = instruction->AsUShrOrNull()->GetRight()->AsIntConstantOrNull()->GetValue(); + *shift_amount = instruction->AsUShr()->GetRight()->AsIntConstant()->GetValue(); } else { DCHECK(instruction->IsTypeConversion()); - // TODO: Remove "OrNull". - DataType::Type result_type = instruction->AsTypeConversionOrNull()->GetResultType(); - // TODO: Remove "OrNull". - DataType::Type input_type = instruction->AsTypeConversionOrNull()->GetInputType(); + DataType::Type result_type = instruction->AsTypeConversion()->GetResultType(); + DataType::Type input_type = instruction->AsTypeConversion()->GetInputType(); int result_size = DataType::Size(result_type); int input_size = DataType::Size(input_type); int min_size = std::min(result_size, input_size); -- cgit v1.2.3-59-g8ed1b