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/instruction_simplifier_shared.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'compiler/optimizing/instruction_simplifier_shared.h') diff --git a/compiler/optimizing/instruction_simplifier_shared.h b/compiler/optimizing/instruction_simplifier_shared.h index fe9d429984..01489f8bcb 100644 --- a/compiler/optimizing/instruction_simplifier_shared.h +++ b/compiler/optimizing/instruction_simplifier_shared.h @@ -26,18 +26,16 @@ namespace helpers { inline bool CanFitInShifterOperand(HInstruction* instruction) { if (instruction->IsTypeConversion()) { - // TODO: Remove "OrNull". - HTypeConversion* conversion = instruction->AsTypeConversionOrNull(); + HTypeConversion* conversion = instruction->AsTypeConversion(); DataType::Type result_type = conversion->GetResultType(); DataType::Type input_type = conversion->GetInputType(); // We don't expect to see the same type as input and result. return DataType::IsIntegralType(result_type) && DataType::IsIntegralType(input_type) && (result_type != input_type); } else { - // TODO: Remove "OrNull". - return (instruction->IsShl() && instruction->AsShlOrNull()->InputAt(1)->IsIntConstant()) || - (instruction->IsShr() && instruction->AsShrOrNull()->InputAt(1)->IsIntConstant()) || - (instruction->IsUShr() && instruction->AsUShrOrNull()->InputAt(1)->IsIntConstant()); + return (instruction->IsShl() && instruction->AsShl()->InputAt(1)->IsIntConstant()) || + (instruction->IsShr() && instruction->AsShr()->InputAt(1)->IsIntConstant()) || + (instruction->IsUShr() && instruction->AsUShr()->InputAt(1)->IsIntConstant()); } } @@ -56,8 +54,7 @@ inline bool HasShifterOperand(HInstruction* instr, InstructionSet isa) { // t3 = Sub(*, t2) inline bool IsSubRightSubLeftShl(HSub *sub) { HInstruction* right = sub->GetRight(); - // TODO: Remove "OrNull". - return right->IsSub() && right->AsSubOrNull()->GetLeft()->IsShl(); + return right->IsSub() && right->AsSub()->GetLeft()->IsShl(); } } // namespace helpers -- cgit v1.2.3-59-g8ed1b