ART: Add HasNonNegativeInputAt and HasNonNegativeOrMinIntInputAt

When it can be quickly checked that an input operand in non-negative,
additional optimizations can be applied during code generation.

The CL adds HasNonNegativeInputAt and HasNonNegativeOrMinIntInputAt
which can be used to check if the input operand of an instruction at
the index is non-negative. They guarantee that at the time of checks
the instruction can have non-negative inputs. Other optimizations after
that might break the invariant.

Optimizations HRem/HDiv for ARM32/ARM64 are moved to used the new methods.

Test: 411-checker-hdiv-hrem-pow2
Test: 411-checker-hdiv-hrem-const
Test: test.py --host --optimizing --jit --gtest --interpreter
Test: test.py -target --optimizing --jit --interpreter
Test: run-gtests.sh
Change-Id: Icf8574699e003bba194097c4e39660de16aa53d9
diff --git a/compiler/optimizing/code_generator_utils.cc b/compiler/optimizing/code_generator_utils.cc
index 9da5201..c19eda4 100644
--- a/compiler/optimizing/code_generator_utils.cc
+++ b/compiler/optimizing/code_generator_utils.cc
@@ -100,15 +100,17 @@
   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);
+
+bool HasNonNegativeInputAt(HInstruction* instr, size_t i) {
+  HInstruction* input = instr->InputAt(i);
+  return IsGEZero(input);
+}
+
+bool HasNonNegativeOrMinIntInputAt(HInstruction* instr, size_t i) {
+  HInstruction* input = instr->InputAt(i);
+  return input->IsAbs() ||
+         IsInt64Value(input, DataType::MinValueOfIntegralType(input->GetType())) ||
+         HasNonNegativeInputAt(instr, i);
 }
 
 }  // namespace art