summaryrefslogtreecommitdiff
path: root/compiler/optimizing/scheduler_arm.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2023-04-05 10:33:07 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2023-04-27 10:52:39 +0000
commit79dc217688a774fc532584f6551a0aec8b45bc4a (patch)
tree5abfe4bd90364e66b593088ab4d1b407b51dada5 /compiler/optimizing/scheduler_arm.cc
parentd60aff547dedefc35265ce57707d406e8ccc4dc6 (diff)
Optimizing: Rename `As##type` to `As##type##OrNull`.
The null type check in the current implementation of `HInstruction::As##type()` often cannot be optimized away by clang++. It is therefore beneficial to have two functions HInstruction::As##type() HInstruction::As##type##OrNull() where the first function never returns null but the second one can return null. The additional text "OrNull" shall also flag the possibility of yielding null to the developer which may help avoid bugs similar to what we have seen previously. This requires renaming the existing function that can return null and introducing new function that cannot. However, defining the new function `HInstruction::As##type()` in the same change as renaming the old one would risk introducing bugs by missing a rename. Therefore we simply rename the old function here and the new function shall be introduced in a separate change with all behavioral changes being explicit. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: buildbot-build.sh --target Bug: 181943478 Change-Id: I4defd85038e28fe3506903ba3f33f723682b3298
Diffstat (limited to 'compiler/optimizing/scheduler_arm.cc')
-rw-r--r--compiler/optimizing/scheduler_arm.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/optimizing/scheduler_arm.cc b/compiler/optimizing/scheduler_arm.cc
index 3f931c4c49..cded09ac67 100644
--- a/compiler/optimizing/scheduler_arm.cc
+++ b/compiler/optimizing/scheduler_arm.cc
@@ -109,7 +109,8 @@ void SchedulingLatencyVisitorARM::VisitRor(HRor* instr) {
// HandleLongRotate
HInstruction* rhs = instr->GetRight();
if (rhs->IsConstant()) {
- uint64_t rot = Uint64ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance;
+ // TODO: Remove "OrNull".
+ uint64_t rot = Uint64ConstantFrom(rhs->AsConstantOrNull()) & kMaxLongShiftDistance;
if (rot != 0u) {
last_visited_internal_latency_ = 3 * kArmIntegerOpLatency;
last_visited_latency_ = kArmIntegerOpLatency;
@@ -143,7 +144,8 @@ void SchedulingLatencyVisitorARM::HandleShiftLatencies(HBinaryOperation* instr)
if (!rhs->IsConstant()) {
last_visited_internal_latency_ = 8 * kArmIntegerOpLatency;
} else {
- uint32_t shift_value = Int32ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance;
+ // TODO: Remove "OrNull".
+ uint32_t shift_value = Int32ConstantFrom(rhs->AsConstantOrNull()) & kMaxLongShiftDistance;
if (shift_value == 1 || shift_value >= 32) {
last_visited_internal_latency_ = kArmIntegerOpLatency;
} else {
@@ -833,7 +835,8 @@ void SchedulingLatencyVisitorARM::VisitDiv(HDiv* instruction) {
case DataType::Type::kInt32: {
HInstruction* rhs = instruction->GetRight();
if (rhs->IsConstant()) {
- int32_t imm = Int32ConstantFrom(rhs->AsConstant());
+ // TODO: Remove "OrNull".
+ int32_t imm = Int32ConstantFrom(rhs->AsConstantOrNull());
HandleDivRemConstantIntegralLatencies(imm);
} else {
last_visited_latency_ = kArmDivIntegerLatency;
@@ -901,7 +904,8 @@ void SchedulingLatencyVisitorARM::VisitRem(HRem* instruction) {
case DataType::Type::kInt32: {
HInstruction* rhs = instruction->GetRight();
if (rhs->IsConstant()) {
- int32_t imm = Int32ConstantFrom(rhs->AsConstant());
+ // TODO: Remove "OrNull".
+ int32_t imm = Int32ConstantFrom(rhs->AsConstantOrNull());
HandleDivRemConstantIntegralLatencies(imm);
} else {
last_visited_internal_latency_ = kArmDivIntegerLatency;