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_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc
index d9a965c..ccb0609 100644
--- a/compiler/optimizing/code_generator_arm_vixl.cc
+++ b/compiler/optimizing/code_generator_arm_vixl.cc
@@ -4241,7 +4241,7 @@
     }
   };
 
-  if (HasNonNegativeResultOrMinInt(instruction->GetLeft())) {
+  if (HasNonNegativeOrMinIntInputAt(instruction, 0)) {
     // No need to adjust the result for non-negative dividends or the INT32_MIN dividend.
     // NOTE: The generated code for HDiv/HRem correctly works for the INT32_MIN dividend:
     //   imm == 2
@@ -4350,7 +4350,7 @@
     }
   };
 
-  if (imm > 0 && IsGEZero(instruction->GetLeft())) {
+  if (imm > 0 && HasNonNegativeInputAt(instruction, 0)) {
     // No need to adjust the result for a non-negative dividend and a positive divisor.
     if (instruction->IsDiv()) {
       generate_unsigned_div_code(out, dividend, temp1, temp2);
@@ -4433,7 +4433,7 @@
         } else if (IsPowerOfTwo(AbsOrMin(value)) &&
                    value != 2 &&
                    value != -2 &&
-                   !HasNonNegativeResultOrMinInt(div)) {
+                   !HasNonNegativeOrMinIntInputAt(div, 0)) {
           // The "out" register is used as a temporary, so it overlaps with the inputs.
           out_overlaps = Location::kOutputOverlap;
         } else {
@@ -4547,7 +4547,7 @@
         Location::OutputOverlap out_overlaps = Location::kNoOutputOverlap;
         if (value == 1 || value == 0 || value == -1) {
           // No temp register required.
-        } else if (IsPowerOfTwo(AbsOrMin(value)) && !HasNonNegativeResultOrMinInt(rem)) {
+        } else if (IsPowerOfTwo(AbsOrMin(value)) && !HasNonNegativeOrMinIntInputAt(rem, 0)) {
           // The "out" register is used as a temporary, so it overlaps with the inputs.
           out_overlaps = Location::kOutputOverlap;
         } else {