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
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 43129d1..0d2c252 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -192,10 +192,8 @@
 bool InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop(HBinaryOperation* binop) {
   DCHECK(binop->IsAdd() || binop->IsSub());
   DCHECK(binop->GetLeft()->IsNeg() && binop->GetRight()->IsNeg());
-  // TODO: Remove "OrNull".
-  HNeg* left_neg = binop->GetLeft()->AsNegOrNull();
-  // TODO: Remove "OrNull".
-  HNeg* right_neg = binop->GetRight()->AsNegOrNull();
+  HNeg* left_neg = binop->GetLeft()->AsNeg();
+  HNeg* right_neg = binop->GetRight()->AsNeg();
   if (!left_neg->HasOnlyOneNonEnvironmentUse() ||
       !right_neg->HasOnlyOneNonEnvironmentUse()) {
     return false;
@@ -315,8 +313,7 @@
   // whether all uses are on different control-flow paths (using dominance and
   // reverse-dominance information) and only perform the merge when they are.
   HInstruction* accumulator = nullptr;
-  // TODO: Remove "OrNull".
-  HVecBinaryOperation* vec_binop = binop->AsVecBinaryOperationOrNull();
+  HVecBinaryOperation* vec_binop = binop->AsVecBinaryOperation();
   HInstruction* binop_left = vec_binop->GetLeft();
   HInstruction* binop_right = vec_binop->GetRight();
   // This is always true since the `HVecMul` has only one use (which is checked above).
@@ -374,8 +371,7 @@
       : kMaxIntShiftDistance;
 
   if (shift_amount->IsConstant()) {
-    // TODO: Remove "OrNull".
-    int64_t cst = Int64FromConstant(shift_amount->AsConstantOrNull());
+    int64_t cst = Int64FromConstant(shift_amount->AsConstant());
     int64_t masked_cst = cst & implicit_mask;
     if (masked_cst == 0) {
       // Replace code looking like
@@ -416,8 +412,7 @@
       shift_amount->IsAdd() ||
       shift_amount->IsSub()) {
     int64_t required_result = shift_amount->IsAnd() ? implicit_mask : 0;
-    // TODO: Remove "OrNull".
-    HBinaryOperation* bin_op = shift_amount->AsBinaryOperationOrNull();
+    HBinaryOperation* bin_op = shift_amount->AsBinaryOperation();
     HConstant* mask = bin_op->GetConstantRight();
     if (mask != nullptr && (Int64FromConstant(mask) & implicit_mask) == required_result) {
       instruction->ReplaceInput(bin_op->GetLeastConstantLeft(), 1);
@@ -429,8 +424,7 @@
     DataType::Type source_type = shift_amount->InputAt(0)->GetType();
     // Non-integral and 64-bit source types require an explicit type conversion.
     if (DataType::IsIntegralType(source_type) && !DataType::Is64BitType(source_type)) {
-      // TODO: Remove "OrNull".
-      instruction->ReplaceInput(shift_amount->AsTypeConversionOrNull()->GetInput(), 1);
+      instruction->ReplaceInput(shift_amount->AsTypeConversion()->GetInput(), 1);
       RecordSimplification();
       return;
     }
@@ -440,8 +434,7 @@
 static bool IsSubRegBitsMinusOther(HSub* sub, size_t reg_bits, HInstruction* other) {
   return (sub->GetRight() == other &&
           sub->GetLeft()->IsConstant() &&
-          // TODO: Remove "OrNull".
-          (Int64FromConstant(sub->GetLeft()->AsConstantOrNull()) & (reg_bits - 1)) == 0);
+          (Int64FromConstant(sub->GetLeft()->AsConstant()) & (reg_bits - 1)) == 0);
 }
 
 bool InstructionSimplifierVisitor::ReplaceRotateWithRor(HBinaryOperation* op,
@@ -474,10 +467,8 @@
   HInstruction* right = op->GetRight();
   // If we have an UShr and a Shl (in either order).
   if ((left->IsUShr() && right->IsShl()) || (left->IsShl() && right->IsUShr())) {
-    // TODO: Remove "OrNull".
-    HUShr* ushr = left->IsUShr() ? left->AsUShrOrNull() : right->AsUShrOrNull();
-    // TODO: Remove "OrNull".
-    HShl* shl = left->IsShl() ? left->AsShlOrNull() : right->AsShlOrNull();
+    HUShr* ushr = left->IsUShr() ? left->AsUShr() : right->AsUShr();
+    HShl* shl = left->IsShl() ? left->AsShl() : right->AsShl();
     DCHECK(DataType::IsIntOrLongType(ushr->GetType()));
     if (ushr->GetType() == shl->GetType() &&
         ushr->GetLeft() == shl->GetLeft()) {
@@ -512,10 +503,8 @@
                                                                        HShl* shl) {
   DCHECK(op->IsAdd() || op->IsXor() || op->IsOr());
   size_t reg_bits = DataType::Size(ushr->GetType()) * kBitsPerByte;
-  // TODO: Remove "OrNull".
-  size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstantOrNull());
-  // TODO: Remove "OrNull".
-  size_t ldist = Int64FromConstant(shl->GetRight()->AsConstantOrNull());
+  size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstant());
+  size_t ldist = Int64FromConstant(shl->GetRight()->AsConstant());
   if (((ldist + rdist) & (reg_bits - 1)) == 0) {
     ReplaceRotateWithRor(op, ushr, shl);
     return true;
@@ -545,8 +534,7 @@
   DCHECK(op->IsAdd() || op->IsXor() || op->IsOr());
   DCHECK(ushr->GetRight()->IsNeg() || shl->GetRight()->IsNeg());
   bool neg_is_left = shl->GetRight()->IsNeg();
-  // TODO: Remove "OrNull".
-  HNeg* neg = neg_is_left ? shl->GetRight()->AsNegOrNull() : ushr->GetRight()->AsNegOrNull();
+  HNeg* neg = neg_is_left ? shl->GetRight()->AsNeg() : ushr->GetRight()->AsNeg();
   // And the shift distance being negated is the distance being shifted the other way.
   if (neg->InputAt(0) == (neg_is_left ? ushr->GetRight() : shl->GetRight())) {
     ReplaceRotateWithRor(op, ushr, shl);
@@ -578,12 +566,8 @@
   size_t reg_bits = DataType::Size(ushr->GetType()) * kBitsPerByte;
   HInstruction* shl_shift = shl->GetRight();
   HInstruction* ushr_shift = ushr->GetRight();
-  if ((shl_shift->IsSub() &&
-       // TODO: Remove "OrNull".
-       IsSubRegBitsMinusOther(shl_shift->AsSubOrNull(), reg_bits, ushr_shift)) ||
-      (ushr_shift->IsSub() &&
-       // TODO: Remove "OrNull".
-       IsSubRegBitsMinusOther(ushr_shift->AsSubOrNull(), reg_bits, shl_shift))) {
+  if ((shl_shift->IsSub() && IsSubRegBitsMinusOther(shl_shift->AsSub(), reg_bits, ushr_shift)) ||
+      (ushr_shift->IsSub() && IsSubRegBitsMinusOther(ushr_shift->AsSub(), reg_bits, shl_shift))) {
     return ReplaceRotateWithRor(op, ushr, shl);
   }
   return false;
@@ -805,14 +789,12 @@
       HBasicBlock* block = equal->GetBlock();
       // We are comparing the boolean to a constant which is of type int and can
       // be any constant.
-      // TODO: Remove "OrNull".
-      if (input_const->AsIntConstantOrNull()->IsTrue()) {
+      if (input_const->AsIntConstant()->IsTrue()) {
         // Replace (bool_value == true) with bool_value
         equal->ReplaceWith(input_value);
         block->RemoveInstruction(equal);
         RecordSimplification();
-        // TODO: Remove "OrNull".
-      } else if (input_const->AsIntConstantOrNull()->IsFalse()) {
+      } else if (input_const->AsIntConstant()->IsFalse()) {
         // Replace (bool_value == false) with !bool_value
         equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, equal));
         block->RemoveInstruction(equal);
@@ -839,14 +821,12 @@
       HBasicBlock* block = not_equal->GetBlock();
       // We are comparing the boolean to a constant which is of type int and can
       // be any constant.
-      // TODO: Remove "OrNull".
-      if (input_const->AsIntConstantOrNull()->IsTrue()) {
+      if (input_const->AsIntConstant()->IsTrue()) {
         // Replace (bool_value != true) with !bool_value
         not_equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, not_equal));
         block->RemoveInstruction(not_equal);
         RecordSimplification();
-        // TODO: Remove "OrNull".
-      } else if (input_const->AsIntConstantOrNull()->IsFalse()) {
+      } else if (input_const->AsIntConstant()->IsFalse()) {
         // Replace (bool_value != false) with bool_value
         not_equal->ReplaceWith(input_value);
         block->RemoveInstruction(not_equal);
@@ -871,12 +851,10 @@
 
   if (input->IsIntConstant()) {
     // Replace !(true/false) with false/true.
-    // TODO: Remove "OrNull".
-    if (input->AsIntConstantOrNull()->IsTrue()) {
+    if (input->AsIntConstant()->IsTrue()) {
       replace_with = GetGraph()->GetIntConstant(0);
     } else {
-      // TODO: Remove "OrNull".
-      DCHECK(input->AsIntConstantOrNull()->IsFalse()) << input->AsIntConstantOrNull()->GetValue();
+      DCHECK(input->AsIntConstant()->IsFalse()) << input->AsIntConstant()->GetValue();
       replace_with = GetGraph()->GetIntConstant(1);
     }
   } else if (input->IsBooleanNot()) {
@@ -887,8 +865,7 @@
              // NaNs forces the compares to be done as written by the user.
              !DataType::IsFloatingPointType(input->InputAt(0)->GetType())) {
     // Replace condition with its opposite.
-    // TODO: Remove "OrNull".
-    replace_with = GetGraph()->InsertOppositeCondition(input->AsConditionOrNull(), bool_not);
+    replace_with = GetGraph()->InsertOppositeCondition(input->AsCondition(), bool_not);
   }
 
   if (replace_with != nullptr) {
@@ -956,10 +933,8 @@
   if (IsInt64AndGet(b, /*out*/ &value) &&
       (((cmp == kCondLT || cmp == kCondLE) && c->IsMax()) ||
        ((cmp == kCondGT || cmp == kCondGE) && c->IsMin()))) {
-    // TODO: Remove "OrNull".
-    HConstant* other = c->AsBinaryOperationOrNull()->GetConstantRight();
-    // TODO: Remove "OrNull".
-    if (other != nullptr && a == c->AsBinaryOperationOrNull()->GetLeastConstantLeft()) {
+    HConstant* other = c->AsBinaryOperation()->GetConstantRight();
+    if (other != nullptr && a == c->AsBinaryOperation()->GetLeastConstantLeft()) {
       int64_t other_value = Int64FromConstant(other);
       bool is_max = (cmp == kCondLT || cmp == kCondLE);
       // Allow the max for a <  100 ? max(a, -100) : ..
@@ -1053,32 +1028,24 @@
     // Replace (cond ? x : x) with (x).
     replace_with = true_value;
   } else if (condition->IsIntConstant()) {
-    // TODO: Remove "OrNull".
-    if (condition->AsIntConstantOrNull()->IsTrue()) {
+    if (condition->AsIntConstant()->IsTrue()) {
       // Replace (true ? x : y) with (x).
       replace_with = true_value;
     } else {
       // Replace (false ? x : y) with (y).
-      // TODO: Remove "OrNull".
-      DCHECK(condition->AsIntConstantOrNull()->IsFalse())
-          << condition->AsIntConstantOrNull()->GetValue();
+      DCHECK(condition->AsIntConstant()->IsFalse()) << condition->AsIntConstant()->GetValue();
       replace_with = false_value;
     }
   } else if (true_value->IsIntConstant() && false_value->IsIntConstant()) {
-    // TODO: Remove "OrNull".
-    if (true_value->AsIntConstantOrNull()->IsTrue() &&
-        false_value->AsIntConstantOrNull()->IsFalse()) {
+    if (true_value->AsIntConstant()->IsTrue() && false_value->AsIntConstant()->IsFalse()) {
       // Replace (cond ? true : false) with (cond).
       replace_with = condition;
-      // TODO: Remove "OrNull".
-    } else if (true_value->AsIntConstantOrNull()->IsFalse() &&
-        false_value->AsIntConstantOrNull()->IsTrue()) {
+    } else if (true_value->AsIntConstant()->IsFalse() && false_value->AsIntConstant()->IsTrue()) {
       // Replace (cond ? false : true) with (!cond).
       replace_with = GetGraph()->InsertOppositeCondition(condition, select);
     }
   } else if (condition->IsCondition()) {
-    // TODO: Remove "OrNull".
-    IfCondition cmp = condition->AsConditionOrNull()->GetCondition();
+    IfCondition cmp = condition->AsCondition()->GetCondition();
     HInstruction* a = condition->InputAt(0);
     HInstruction* b = condition->InputAt(1);
     DataType::Type t_type = true_value->GetType();
@@ -1159,8 +1126,7 @@
   // If the array is a NewArray with constant size, replace the array length
   // with the constant instruction. This helps the bounds check elimination phase.
   if (input->IsNewArray()) {
-    // TODO: Remove "OrNull".
-    input = input->AsNewArrayOrNull()->GetLength();
+    input = input->AsNewArray()->GetLength();
     if (input->IsIntConstant()) {
       instruction->ReplaceWith(input);
     }
@@ -1178,8 +1144,7 @@
   }
 
   if (value->IsArrayGet()) {
-    // TODO: Remove "OrNull".
-    if (value->AsArrayGetOrNull()->GetArray() == instruction->GetArray()) {
+    if (value->AsArrayGet()->GetArray() == instruction->GetArray()) {
       // If the code is just swapping elements in the array, no need for a type check.
       instruction->ClearTypeCheck();
       return;
@@ -1255,21 +1220,16 @@
 
 static inline bool TryReplaceFieldOrArrayGetType(HInstruction* maybe_get, DataType::Type new_type) {
   if (maybe_get->IsInstanceFieldGet()) {
-    // TODO: Remove "OrNull".
-    maybe_get->AsInstanceFieldGetOrNull()->SetType(new_type);
+    maybe_get->AsInstanceFieldGet()->SetType(new_type);
     return true;
   } else if (maybe_get->IsPredicatedInstanceFieldGet()) {
-    // TODO: Remove "OrNull".
-    maybe_get->AsPredicatedInstanceFieldGetOrNull()->SetType(new_type);
+    maybe_get->AsPredicatedInstanceFieldGet()->SetType(new_type);
     return true;
   } else if (maybe_get->IsStaticFieldGet()) {
-    // TODO: Remove "OrNull".
-    maybe_get->AsStaticFieldGetOrNull()->SetType(new_type);
+    maybe_get->AsStaticFieldGet()->SetType(new_type);
     return true;
-    // TODO: Remove "OrNull".
-  } else if (maybe_get->IsArrayGet() && !maybe_get->AsArrayGetOrNull()->IsStringCharAt()) {
-    // TODO: Remove "OrNull".
-    maybe_get->AsArrayGetOrNull()->SetType(new_type);
+  } else if (maybe_get->IsArrayGet() && !maybe_get->AsArrayGet()->IsStringCharAt()) {
+    maybe_get->AsArrayGet()->SetType(new_type);
     return true;
   } else {
     return false;
@@ -1304,27 +1264,20 @@
   for (const HUseListNode<HInstruction*>& use : type_conversion->GetUses()) {
     HInstruction* instruction = use.GetUser();
     if (instruction->IsInstanceFieldSet() &&
-        // TODO: Remove "OrNull".
-        instruction->AsInstanceFieldSetOrNull()->GetFieldType() == result_type) {
-      // TODO: Remove "OrNull".
-      DCHECK_EQ(instruction->AsInstanceFieldSetOrNull()->GetValue(), type_conversion);
+        instruction->AsInstanceFieldSet()->GetFieldType() == result_type) {
+      DCHECK_EQ(instruction->AsInstanceFieldSet()->GetValue(), type_conversion);
       continue;
     }
     if (instruction->IsStaticFieldSet() &&
-        // TODO: Remove "OrNull".
-        instruction->AsStaticFieldSetOrNull()->GetFieldType() == result_type) {
-      // TODO: Remove "OrNull".
-      DCHECK_EQ(instruction->AsStaticFieldSetOrNull()->GetValue(), type_conversion);
+        instruction->AsStaticFieldSet()->GetFieldType() == result_type) {
+      DCHECK_EQ(instruction->AsStaticFieldSet()->GetValue(), type_conversion);
       continue;
     }
     if (instruction->IsArraySet() &&
-        // TODO: Remove "OrNull".
-        instruction->AsArraySetOrNull()->GetComponentType() == result_type &&
+        instruction->AsArraySet()->GetComponentType() == result_type &&
         // not index use.
-        // TODO: Remove "OrNull".
-        instruction->AsArraySetOrNull()->GetIndex() != type_conversion) {
-      // TODO: Remove "OrNull".
-      DCHECK_EQ(instruction->AsArraySetOrNull()->GetValue(), type_conversion);
+        instruction->AsArraySet()->GetIndex() != type_conversion) {
+      DCHECK_EQ(instruction->AsArraySet()->GetValue(), type_conversion);
       continue;
     }
     // The use is not as a store value, or the field/element type is not the
@@ -1347,8 +1300,7 @@
   }
 
   if (input->IsTypeConversion()) {
-    // TODO: Remove "OrNull".
-    HTypeConversion* input_conversion = input->AsTypeConversionOrNull();
+    HTypeConversion* input_conversion = input->AsTypeConversion();
     HInstruction* original_input = input_conversion->GetInput();
     DataType::Type original_type = original_input->GetType();
 
@@ -1390,14 +1342,12 @@
             // Optimization only applies to lossy Type Conversions.
             !IsTypeConversionLossless(input_type, result_type)) {
     DCHECK(DataType::IsIntegralType(input_type));
-    // TODO: Remove "OrNull".
-    HShr* shr_op = input->AsShrOrNull();
+    HShr* shr_op = input->AsShr();
     HConstant* shr_right = shr_op->GetConstantRight();
     HInstruction* shr_left = shr_op->GetLeastConstantLeft();
     if (shr_right != nullptr && shr_left->IsAnd()) {
       // Optimization needs AND -> SHR -> TypeConversion pattern.
-      // TODO: Remove "OrNull".
-      HAnd* and_op = shr_left->AsAndOrNull();
+      HAnd* and_op = shr_left->AsAnd();
       HConstant* and_right = and_op->GetConstantRight();
       HInstruction* and_left = and_op->GetLeastConstantLeft();
       if (and_right != nullptr &&
@@ -1420,8 +1370,7 @@
     }
   } else if (input->IsAnd() && DataType::IsIntegralType(result_type)) {
     DCHECK(DataType::IsIntegralType(input_type));
-    // TODO: Remove "OrNull".
-    HAnd* input_and = input->AsAndOrNull();
+    HAnd* input_and = input->AsAnd();
     HConstant* constant = input_and->GetConstantRight();
     if (constant != nullptr) {
       int64_t value = Int64FromConstant(constant);
@@ -1507,8 +1456,7 @@
     }
   }
 
-  // TODO: Remove first "OrNull", keep the second.
-  HNeg* neg = left_is_neg ? left->AsNegOrNull() : right->AsNegOrNull();
+  HNeg* neg = left_is_neg ? left->AsNeg() : right->AsNegOrNull();
   if (left_is_neg != right_is_neg && neg->HasOnlyOneNonEnvironmentUse()) {
     // Replace code looking like
     //    NEG tmp, b
@@ -1619,9 +1567,7 @@
     // precisely clears the shifted-in sign bits.
     if ((input_other->IsUShr() || input_other->IsShr()) && input_other->InputAt(1)->IsConstant()) {
       size_t reg_bits = (instruction->GetResultType() == DataType::Type::kInt64) ? 64 : 32;
-      // TODO: Remove "OrNull".
-      size_t shift =
-          Int64FromConstant(input_other->InputAt(1)->AsConstantOrNull()) & (reg_bits - 1);
+      size_t shift = Int64FromConstant(input_other->InputAt(1)->AsConstant()) & (reg_bits - 1);
       size_t num_tail_bits_set = CTZ(value + 1);
       if ((num_tail_bits_set >= reg_bits - shift) && input_other->IsUShr()) {
         // This AND clears only bits known to be clear, for example "(x >>> 24) & 0xff".
@@ -1729,8 +1675,7 @@
   HInstruction* input_one = condition->InputAt(0);
   HInstruction* input_two = condition->InputAt(1);
   HLoadClass* load_class = input_one->IsLoadClass()
-      // TODO: Remove "OrNull".
-      ? input_one->AsLoadClassOrNull()
+      ? input_one->AsLoadClass()
       : input_two->AsLoadClassOrNull();
   if (load_class == nullptr) {
     return false;
@@ -1810,8 +1755,7 @@
   // We can only replace an HCondition which compares a Compare to 0.
   // Both 'dx' and 'jack' generate a compare to 0 when compiling a
   // condition with a long, float or double comparison as input.
-  // TODO: Remove "OrNull".
-  if (!left->IsCompare() || !right->IsConstant() || right->AsIntConstantOrNull()->GetValue() != 0) {
+  if (!left->IsCompare() || !right->IsConstant() || right->AsIntConstant()->GetValue() != 0) {
     // Conversion is not possible.
     return;
   }
@@ -1838,8 +1782,7 @@
   left->RemoveEnvironmentUsers();
 
   // We have decided to fold the HCompare into the HCondition. Transfer the information.
-  // TODO: Remove "OrNull".
-  condition->SetBias(left->AsCompareOrNull()->GetBias());
+  condition->SetBias(left->AsCompare()->GetBias());
 
   // Replace the operands of the HCondition.
   condition->ReplaceInput(left->InputAt(0), 0);
@@ -1897,15 +1840,13 @@
     //    MUL dst, src, 1 / constant
     HConstant* reciprocal = nullptr;
     if (type == DataType::Type::kFloat64) {
-      // TODO: Remove "OrNull".
-      double value = input_cst->AsDoubleConstantOrNull()->GetValue();
+      double value = input_cst->AsDoubleConstant()->GetValue();
       if (CanDivideByReciprocalMultiplyDouble(bit_cast<int64_t, double>(value))) {
         reciprocal = GetGraph()->GetDoubleConstant(1.0 / value);
       }
     } else {
       DCHECK_EQ(type, DataType::Type::kFloat32);
-      // TODO: Remove "OrNull".
-      float value = input_cst->AsFloatConstantOrNull()->GetValue();
+      float value = input_cst->AsFloatConstant()->GetValue();
       if (CanDivideByReciprocalMultiplyFloat(bit_cast<int32_t, float>(value))) {
         reciprocal = GetGraph()->GetFloatConstant(1.0f / value);
       }
@@ -1932,8 +1873,7 @@
         user->IsDiv() &&
         user->InputAt(0) == dividend &&
         user->InputAt(1) == divisor) {
-      // TODO: Remove "OrNull".
-      return user->AsDivOrNull();
+      return user->AsDiv();
     }
   }
   return nullptr;
@@ -2023,10 +1963,9 @@
     return;
   }
 
-  // TODO: Remove "OrNull".
   if (DataType::IsFloatingPointType(type) &&
-      ((input_cst->IsFloatConstant() && input_cst->AsFloatConstantOrNull()->GetValue() == 2.0f) ||
-       (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstantOrNull()->GetValue() == 2.0))) {
+      ((input_cst->IsFloatConstant() && input_cst->AsFloatConstant()->GetValue() == 2.0f) ||
+       (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstant()->GetValue() == 2.0))) {
     // Replace code looking like
     //    FP_MUL dst, src, 2.0
     // with
@@ -2107,8 +2046,7 @@
     //    NEG dst, tmp
     // with
     //    src
-    // TODO: Remove "OrNull".
-    HNeg* previous_neg = input->AsNegOrNull();
+    HNeg* previous_neg = input->AsNeg();
     instruction->ReplaceWith(previous_neg->GetInput());
     instruction->GetBlock()->RemoveInstruction(instruction);
     // We perform the optimization even if the input negation has environment
@@ -2134,8 +2072,7 @@
     // to be extended if we are not sure the initial 'SUB' instruction can be
     // removed.
     // We do not perform optimization for fp because we could lose the sign of zero.
-    // TODO: Remove "OrNull".
-    HSub* sub = input->AsSubOrNull();
+    HSub* sub = input->AsSub();
     HSub* new_sub = new (GetGraph()->GetAllocator()) HSub(
         instruction->GetType(), sub->GetRight(), sub->GetLeft());
     instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, new_sub);
@@ -2157,8 +2094,7 @@
     // We perform the optimization even if the input negation has environment
     // uses since it allows removing the current instruction. But we only delete
     // the input negation only if it is does not have any uses left.
-    // TODO: Remove "OrNull".
-    HNot* previous_not = input->AsNotOrNull();
+    HNot* previous_not = input->AsNot();
     instruction->ReplaceWith(previous_not->GetInput());
     instruction->GetBlock()->RemoveInstruction(instruction);
     if (!previous_not->HasUses()) {
@@ -2245,8 +2181,7 @@
   HInstruction* left = instruction->GetLeft();
   HInstruction* right = instruction->GetRight();
   if (left->IsConstant()) {
-    // TODO: Remove "OrNull".
-    if (Int64FromConstant(left->AsConstantOrNull()) == 0) {
+    if (Int64FromConstant(left->AsConstant()) == 0) {
       // Replace code looking like
       //    SUB dst, 0, src
       // with
@@ -2273,8 +2208,7 @@
     //    SUB dst, a, tmp
     // with
     //    ADD dst, a, b
-    // TODO: Remove "OrNull".
-    HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left, right->AsNegOrNull()->GetInput());
+    HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left, right->AsNeg()->GetInput());
     instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, add);
     RecordSimplification();
     right->GetBlock()->RemoveInstruction(right);
@@ -2290,8 +2224,7 @@
     //    NEG dst, tmp
     // The second version is not intrinsically better, but enables more
     // transformations.
-    // TODO: Remove "OrNull".
-    HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left->AsNegOrNull()->GetInput(), right);
+    HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left->AsNeg()->GetInput(), right);
     instruction->GetBlock()->InsertInstructionBefore(add, instruction);
     HNeg* neg = new (GetGraph()->GetAllocator()) HNeg(instruction->GetType(), add);
     instruction->GetBlock()->InsertInstructionBefore(neg, instruction);
@@ -2431,8 +2364,7 @@
   }
 
   if (potential_array->IsNewArray()) {
-    // TODO: Remove "OrNull".
-    return potential_array->AsNewArrayOrNull()->GetLength() == potential_length;
+    return potential_array->AsNewArray()->GetLength() == potential_length;
   }
 
   return false;
@@ -2499,8 +2431,7 @@
         (source_component_type == destination_component_type)) {
       ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
       PointerSize image_size = class_linker->GetImagePointerSize();
-      // TODO: Remove "OrNull".
-      HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirectOrNull();
+      HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirect();
       ObjPtr<mirror::Class> system = invoke->GetResolvedMethod()->GetDeclaringClass();
       ArtMethod* method = nullptr;
       switch (source_component_type) {
@@ -2616,8 +2547,7 @@
   DCHECK(invoke->GetIntrinsic() == Intrinsics::kStringIndexOf ||
          invoke->GetIntrinsic() == Intrinsics::kStringIndexOfAfter);
   if (invoke->InputAt(0)->IsLoadString()) {
-    // TODO: Remove "OrNull".
-    HLoadString* load_string = invoke->InputAt(0)->AsLoadStringOrNull();
+    HLoadString* load_string = invoke->InputAt(0)->AsLoadString();
     const DexFile& dex_file = load_string->GetDexFile();
     uint32_t utf16_length;
     const char* data =
@@ -2673,13 +2603,11 @@
 static bool NoEscapeForStringBufferReference(HInstruction* reference, HInstruction* user) {
   if (user->IsInvokeStaticOrDirect()) {
     // Any constructor on StringBuffer is okay.
-    // TODO: Remove "OrNull".
-    return user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod() != nullptr &&
-           user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod()->IsConstructor() &&
+    return user->AsInvokeStaticOrDirect()->GetResolvedMethod() != nullptr &&
+           user->AsInvokeStaticOrDirect()->GetResolvedMethod()->IsConstructor() &&
            user->InputAt(0) == reference;
   } else if (user->IsInvokeVirtual()) {
-    // TODO: Remove "OrNull".
-    switch (user->AsInvokeVirtualOrNull()->GetIntrinsic()) {
+    switch (user->AsInvokeVirtual()->GetIntrinsic()) {
       case Intrinsics::kStringBufferLength:
       case Intrinsics::kStringBufferToString:
         DCHECK_EQ(user->InputAt(0), reference);
@@ -2750,8 +2678,7 @@
     }
     // Then we should see the arguments.
     if (user->IsInvokeVirtual()) {
-      // TODO: Remove "OrNull".
-      HInvokeVirtual* as_invoke_virtual = user->AsInvokeVirtualOrNull();
+      HInvokeVirtual* as_invoke_virtual = user->AsInvokeVirtual();
       DCHECK(!seen_constructor);
       DCHECK(!seen_constructor_fence);
       StringBuilderAppend::Argument arg;
@@ -2787,8 +2714,7 @@
           has_fp_args = true;
           break;
         case Intrinsics::kStringBuilderAppendCharSequence: {
-          // TODO: Remove "OrNull".
-          ReferenceTypeInfo rti = user->AsInvokeVirtualOrNull()->InputAt(1)->GetReferenceTypeInfo();
+          ReferenceTypeInfo rti = user->AsInvokeVirtual()->InputAt(1)->GetReferenceTypeInfo();
           if (!rti.IsValid()) {
             return false;
           }
@@ -2820,12 +2746,9 @@
       args[num_args] = as_invoke_virtual->InputAt(1u);
       ++num_args;
     } else if (user->IsInvokeStaticOrDirect() &&
-               // TODO: Remove "OrNull".
-               user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod() != nullptr &&
-               // TODO: Remove "OrNull".
-               user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod()->IsConstructor() &&
-               // TODO: Remove "OrNull".
-               user->AsInvokeStaticOrDirectOrNull()->GetNumberOfArguments() == 1u) {
+               user->AsInvokeStaticOrDirect()->GetResolvedMethod() != nullptr &&
+               user->AsInvokeStaticOrDirect()->GetResolvedMethod()->IsConstructor() &&
+               user->AsInvokeStaticOrDirect()->GetNumberOfArguments() == 1u) {
       // After arguments, we should see the constructor.
       // We accept only the constructor with no extra arguments.
       DCHECK(!seen_constructor);
@@ -2964,8 +2887,7 @@
   if (!var_handle_instruction->IsStaticFieldGet()) {
     return false;
   }
-  // TODO: Remove "OrNull".
-  ArtField* field = var_handle_instruction->AsStaticFieldGetOrNull()->GetFieldInfo().GetField();
+  ArtField* field = var_handle_instruction->AsStaticFieldGet()->GetFieldInfo().GetField();
   DCHECK(field->IsStatic());
   if (!field->IsFinal()) {
     return false;
@@ -2988,11 +2910,9 @@
       is_in_boot_image = compiler_options.IsImageClass(descriptor);
     }
     CHECK_EQ(is_in_boot_image,
-             // TODO: Remove "OrNull".
-             load_class->IsLoadClass() && load_class->AsLoadClassOrNull()->IsInBootImage());
+             load_class->IsLoadClass() && load_class->AsLoadClass()->IsInBootImage());
   }
-  // TODO: Remove "OrNull".
-  if (!load_class->IsLoadClass() || !load_class->AsLoadClassOrNull()->IsInBootImage()) {
+  if (!load_class->IsLoadClass() || !load_class->AsLoadClass()->IsInBootImage()) {
     return false;
   }
 
@@ -3188,8 +3108,7 @@
 void InstructionSimplifierVisitor::VisitDeoptimize(HDeoptimize* deoptimize) {
   HInstruction* cond = deoptimize->InputAt(0);
   if (cond->IsConstant()) {
-    // TODO: Remove "OrNull".
-    if (cond->AsIntConstantOrNull()->IsFalse()) {
+    if (cond->AsIntConstant()->IsFalse()) {
       // Never deopt: instruction can be removed.
       if (deoptimize->GuardsAnInput()) {
         deoptimize->ReplaceWith(deoptimize->GuardedInput());
@@ -3222,15 +3141,11 @@
   HBinaryOperation* y;
 
   if (instruction->GetKind() == left->GetKind() && right->IsConstant()) {
-    // TODO: Remove "OrNull".
-    const2 = right->AsConstantOrNull();
-    // TODO: Remove "OrNull".
-    y = left->AsBinaryOperationOrNull();
+    const2 = right->AsConstant();
+    y = left->AsBinaryOperation();
   } else if (left->IsConstant() && instruction->GetKind() == right->GetKind()) {
-    // TODO: Remove "OrNull".
-    const2 = left->AsConstantOrNull();
-    // TODO: Remove "OrNull".
-    y = right->AsBinaryOperationOrNull();
+    const2 = left->AsConstant();
+    y = right->AsBinaryOperation();
   } else {
     // The node does not match the pattern.
     return false;
@@ -3261,8 +3176,7 @@
 }
 
 static HBinaryOperation* AsAddOrSub(HInstruction* binop) {
-  // TODO: Remove "OrNull".
-  return (binop->IsAdd() || binop->IsSub()) ? binop->AsBinaryOperationOrNull() : nullptr;
+  return (binop->IsAdd() || binop->IsSub()) ? binop->AsBinaryOperation() : nullptr;
 }
 
 // Helper function that performs addition statically, considering the result type.
@@ -3301,15 +3215,13 @@
   HInstruction* left = instruction->GetLeft();
   HInstruction* right = instruction->GetRight();
   // Variable names as described above.
-  // TODO: Remove first "OrNull", keep the second.
-  HConstant* const2 = right->IsConstant() ? right->AsConstantOrNull() : left->AsConstantOrNull();
+  HConstant* const2 = right->IsConstant() ? right->AsConstant() : left->AsConstantOrNull();
   if (const2 == nullptr) {
     return false;
   }
 
   HBinaryOperation* y = (AsAddOrSub(left) != nullptr)
-      // TODO: Remove "OrNull".
-      ? left->AsBinaryOperationOrNull()
+      ? left->AsBinaryOperation()
       : AsAddOrSub(right);
   // If y has more than one use, we do not perform the optimization because
   // it might increase code size (e.g. if the new constant is no longer
@@ -3319,9 +3231,7 @@
   }
 
   left = y->GetLeft();
-  // TODO: Remove first "OrNull", keep the second.
-  HConstant* const1 =
-      left->IsConstant() ? left->AsConstantOrNull() : y->GetRight()->AsConstantOrNull();
+  HConstant* const1 = left->IsConstant() ? left->AsConstant() : y->GetRight()->AsConstantOrNull();
   if (const1 == nullptr) {
     return false;
   }