ART: fix NullCheckElimination to preserve MIR_IGNORE_NULL_CHECK

If the MIRGraph::EliminateNullChecksAndInferTypes() function managed
to prove that some regs are non-null then it sets the flag
MIR_IGNORE_NULL_CHECK and resets this flag for all the other regs.
If some previous optimizations have already set MIR_IGNORE_NULL_CHECK
then it can be reset by EliminateNullChecksAndInferTypes. This way
NullCheckElimination discards some optimization efforts.
Optimization passes should not reset MIR_IGNORE_NULL_CHECK unless
they 100% sure NullCheck is needed.

This patch makes the NCE_TypeInference pass be conservative in
resetting MIR_IGNORE_NULL_CHECK.

Change-Id: I4ea74020968b5c5bd8e3af48211ffd4c6afd7f80
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index dac71f6..fda6ef8 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -936,7 +936,7 @@
         mir->optimization_flags |= MIR_IGNORE_NULL_CHECK;
       } else {
         // Do the null check.
-        mir->optimization_flags &= ~MIR_IGNORE_NULL_CHECK;
+        // Do not clear MIR_IGNORE_NULL_CHECK flag as it may be set by another optimization
         // Mark s_reg as null-checked
         ssa_regs_to_check->ClearBit(src_sreg);
       }