summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generator_utils.cc
diff options
context:
space:
mode:
authorEvgeny Astigeevich <evgeny.astigeevich@linaro.org>2020-06-26 13:28:33 +0100
committerNicolas Geoffray <ngeoffray@google.com>2020-07-02 10:49:08 +0000
commitaf92a0f06fe3ab2618ccc220df3dacc3a20d8bb1 (patch)
treea1825765fba713b9805a26b35743506907cdefe8 /compiler/optimizing/code_generator_utils.cc
parent8d799686ff11ef800a8489272f4e0b36b6ab21b3 (diff)
ARM: Optimize Div/Rem by 2^n for non-negative dividends
When it can be proved that dividends are non-negative or the min integer if their type is integral, there is no need to generate instructions correcting the result. The CL implements this optimization for ARM32/ARM64. Test: 411-checker-hdiv-hrem-pow2 Test: test.py --host --optimizing --jit --gtest --interpreter Test: test.py -target --optimizing --jit --interpreter Test: run-gtests.sh Change-Id: I11211a42918b5801fce8e78f305e69549739c23c
Diffstat (limited to 'compiler/optimizing/code_generator_utils.cc')
-rw-r--r--compiler/optimizing/code_generator_utils.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator_utils.cc b/compiler/optimizing/code_generator_utils.cc
index dd47a1fc6c..9da520161f 100644
--- a/compiler/optimizing/code_generator_utils.cc
+++ b/compiler/optimizing/code_generator_utils.cc
@@ -100,4 +100,15 @@ bool IsBooleanValueOrMaterializedCondition(HInstruction* cond_input) {
return !cond_input->IsCondition() || !cond_input->IsEmittedAtUseSite();
}
+bool HasNonNegativeResultOrMinInt(HInstruction* instruction) {
+ // 1. The instruction itself has always a non-negative result or the min value of
+ // the integral type if the instruction has the integral type.
+ // 2. TODO: The instruction can be an expression which uses an induction variable.
+ // Induction variable often start from 0 and are only increased. Such an
+ // expression might be always non-negative.
+ return instruction->IsAbs() ||
+ IsInt64Value(instruction, DataType::MinValueOfIntegralType(instruction->GetType())) ||
+ IsGEZero(instruction);
+}
+
} // namespace art