summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier_shared.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2023-04-25 16:40:06 +0000
committer Vladimir Marko <vmarko@google.com> 2023-04-27 10:53:55 +0000
commitcde6497d286337de2ed21c71c85157e2745b742b (patch)
tree087d790efb6987f5aab1da7cd91b89bedcdc5725 /compiler/optimizing/instruction_simplifier_shared.cc
parent79dc217688a774fc532584f6551a0aec8b45bc4a (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/instruction_simplifier_shared.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier_shared.cc37
1 files changed, 12 insertions, 25 deletions
diff --git a/compiler/optimizing/instruction_simplifier_shared.cc b/compiler/optimizing/instruction_simplifier_shared.cc
index 3357e53737..34daae21ee 100644
--- a/compiler/optimizing/instruction_simplifier_shared.cc
+++ b/compiler/optimizing/instruction_simplifier_shared.cc
@@ -52,8 +52,7 @@ bool TrySimpleMultiplyAccumulatePatterns(HMul* mul,
} else {
DCHECK(input_binop->IsSub());
if (input_binop->GetRight()->IsConstant() &&
- // TODO: Remove "OrNull".
- input_binop->GetRight()->AsConstantOrNull()->IsMinusOne()) {
+ input_binop->GetRight()->AsConstant()->IsMinusOne()) {
// Interpret
// a * (b - (-1))
// as
@@ -61,8 +60,7 @@ bool TrySimpleMultiplyAccumulatePatterns(HMul* mul,
input_b = input_binop->GetLeft();
op_kind = HInstruction::kAdd;
} else if (input_binop->GetLeft()->IsConstant() &&
- // TODO: Remove "OrNull".
- input_binop->GetLeft()->AsConstantOrNull()->IsOne()) {
+ input_binop->GetLeft()->AsConstant()->IsOne()) {
// Interpret
// a * (1 - b)
// as
@@ -124,8 +122,7 @@ bool TryCombineMultiplyAccumulate(HMul* mul, InstructionSet isa) {
// whether all uses are on different control-flow paths (using dominance and
// reverse-dominance information) and only perform the merge when they are.
HInstruction* accumulator = nullptr;
- // TODO: Remove "OrNull".
- HBinaryOperation* binop = use->AsBinaryOperationOrNull();
+ HBinaryOperation* binop = use->AsBinaryOperation();
HInstruction* binop_left = binop->GetLeft();
HInstruction* binop_right = binop->GetRight();
// Be careful after GVN. This should not happen since the `HMul` has only
@@ -178,13 +175,11 @@ bool TryCombineMultiplyAccumulate(HMul* mul, InstructionSet isa) {
HInstruction* left = mul->GetLeft();
HInstruction* right = mul->GetRight();
if ((right->IsAdd() || right->IsSub()) &&
- // TODO: Remove "OrNull".
- TrySimpleMultiplyAccumulatePatterns(mul, right->AsBinaryOperationOrNull(), left)) {
+ TrySimpleMultiplyAccumulatePatterns(mul, right->AsBinaryOperation(), left)) {
return true;
}
if ((left->IsAdd() || left->IsSub()) &&
- // TODO: Remove "OrNull".
- TrySimpleMultiplyAccumulatePatterns(mul, left->AsBinaryOperationOrNull(), right)) {
+ TrySimpleMultiplyAccumulatePatterns(mul, left->AsBinaryOperation(), right)) {
return true;
}
return false;
@@ -219,8 +214,7 @@ bool TryMergeNegatedInput(HBinaryOperation* op) {
// AND dst, src, tmp (respectively ORR, EOR)
// with
// BIC dst, src, mask (respectively ORN, EON)
- // TODO: Remove "OrNull".
- HInstruction* src = hnot->AsNotOrNull()->GetInput();
+ HInstruction* src = hnot->AsNot()->GetInput();
HBitwiseNegatedRight* neg_op = new (hnot->GetBlock()->GetGraph()->GetAllocator())
HBitwiseNegatedRight(op->GetType(), op->GetKind(), hother, src, op->GetDexPc());
@@ -240,15 +234,13 @@ bool TryExtractArrayAccessAddress(HInstruction* access,
HInstruction* index,
size_t data_offset) {
if (index->IsConstant() ||
- // TODO: Remove "OrNull".
- (index->IsBoundsCheck() && index->AsBoundsCheckOrNull()->GetIndex()->IsConstant())) {
+ (index->IsBoundsCheck() && index->AsBoundsCheck()->GetIndex()->IsConstant())) {
// When the index is a constant all the addressing can be fitted in the
// memory access instruction, so do not split the access.
return false;
}
if (access->IsArraySet() &&
- // TODO: Remove "OrNull".
- access->AsArraySetOrNull()->GetValue()->GetType() == DataType::Type::kReference) {
+ access->AsArraySet()->GetValue()->GetType() == DataType::Type::kReference) {
// The access may require a runtime call or the original array pointer.
return false;
}
@@ -308,8 +300,7 @@ bool TryExtractVecArrayAccessAddress(HVecMemoryOperation* access, HInstruction*
for (const HUseListNode<HInstruction*>& use : index->GetUses()) {
HInstruction* user = use.GetUser();
if (user->IsVecMemoryOperation() && user != access) {
- // TODO: Remove "OrNull".
- HVecMemoryOperation* another_access = user->AsVecMemoryOperationOrNull();
+ HVecMemoryOperation* another_access = user->AsVecMemoryOperation();
DataType::Type another_packed_type = another_access->GetPackedType();
uint32_t another_data_offset = mirror::Array::DataOffset(
DataType::Size(another_packed_type)).Uint32Value();
@@ -319,13 +310,9 @@ bool TryExtractVecArrayAccessAddress(HVecMemoryOperation* access, HInstruction*
break;
}
} else if (user->IsIntermediateAddressIndex()) {
- // TODO: Remove "OrNull".
- HIntermediateAddressIndex* another_access = user->AsIntermediateAddressIndexOrNull();
- // TODO: Remove "OrNull".
- uint32_t another_data_offset = another_access->GetOffset()->AsIntConstantOrNull()->GetValue();
- // TODO: Remove "OrNull".
- size_t another_component_shift =
- another_access->GetShift()->AsIntConstantOrNull()->GetValue();
+ HIntermediateAddressIndex* another_access = user->AsIntermediateAddressIndex();
+ uint32_t another_data_offset = another_access->GetOffset()->AsIntConstant()->GetValue();
+ size_t another_component_shift = another_access->GetShift()->AsIntConstant()->GetValue();
if (another_data_offset == data_offset && another_component_shift == component_shift) {
is_extracting_beneficial = true;
break;