summaryrefslogtreecommitdiff
path: root/compiler/optimizing/induction_var_range.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/induction_var_range.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/induction_var_range.cc')
-rw-r--r--compiler/optimizing/induction_var_range.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc
index 107a2c38da..9b78699ead 100644
--- a/compiler/optimizing/induction_var_range.cc
+++ b/compiler/optimizing/induction_var_range.cc
@@ -171,9 +171,8 @@ bool UseFullTripCount(const HBasicBlock* context, const HLoopInformation* loop,
// one edge leaving the loop. The loop header is the only block that's both inside
// the loop and not in the loop body.
DCHECK(GetLoopControl(loop)->IsIf());
- // TODO: Remove "OrNull".
- DCHECK_NE(loop->Contains(*GetLoopControl(loop)->AsIfOrNull()->IfTrueSuccessor()),
- loop->Contains(*GetLoopControl(loop)->AsIfOrNull()->IfFalseSuccessor()));
+ DCHECK_NE(loop->Contains(*GetLoopControl(loop)->AsIf()->IfTrueSuccessor()),
+ loop->Contains(*GetLoopControl(loop)->AsIf()->IfFalseSuccessor()));
if (loop->Contains(*context)) {
// Use the full trip count if determining the maximum and context is not in the loop body.
DCHECK_NE(context == loop->GetHeader(), IsContextInBody(context, loop));
@@ -183,10 +182,8 @@ bool UseFullTripCount(const HBasicBlock* context, const HLoopInformation* loop,
// as long as the `context` is dominated by the loop control exit block.
// If there are additional exit edges, the value is unknown on those paths.
HInstruction* loop_control = GetLoopControl(loop);
- // TODO: Remove "OrNull".
- HBasicBlock* then_block = loop_control->AsIfOrNull()->IfTrueSuccessor();
- // TODO: Remove "OrNull".
- HBasicBlock* else_block = loop_control->AsIfOrNull()->IfFalseSuccessor();
+ HBasicBlock* then_block = loop_control->AsIf()->IfTrueSuccessor();
+ HBasicBlock* else_block = loop_control->AsIf()->IfFalseSuccessor();
HBasicBlock* loop_exit_block = loop->Contains(*then_block) ? else_block : then_block;
return loop_exit_block->Dominates(context);
}
@@ -738,15 +735,13 @@ InductionVarRange::Value InductionVarRange::GetFetch(const HBasicBlock* context,
return is_min ? Value(0) : Value(std::numeric_limits<int32_t>::max());
} else if (instruction->InputAt(0)->IsNewArray()) {
return GetFetch(
- // TODO: Remove "OrNull".
- context, loop, instruction->InputAt(0)->AsNewArrayOrNull()->GetLength(), trip, is_min);
+ context, loop, instruction->InputAt(0)->AsNewArray()->GetLength(), trip, is_min);
}
} else if (instruction->IsTypeConversion()) {
// Since analysis is 32-bit (or narrower), chase beyond widening along the path.
// For example, this discovers the length in: for (long i = 0; i < a.length; i++);
- // TODO: Remove "OrNull".
- if (instruction->AsTypeConversionOrNull()->GetInputType() == DataType::Type::kInt32 &&
- instruction->AsTypeConversionOrNull()->GetResultType() == DataType::Type::kInt64) {
+ if (instruction->AsTypeConversion()->GetInputType() == DataType::Type::kInt32 &&
+ instruction->AsTypeConversion()->GetResultType() == DataType::Type::kInt64) {
return GetFetch(context, loop, instruction->InputAt(0), trip, is_min);
}
}