Mul simplification should expect zero operand

It is possible that zero constant can appear due to
simplification of other instructions, so we cannot expect
zero handling from constant optimizations.

Change-Id: I084126fd0c106ac2683c4f10a451960d9807f4f6
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 98c0eed..225af77 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -427,9 +427,16 @@
 
   if (Primitive::IsIntOrLongType(type)) {
     int64_t factor = Int64FromConstant(input_cst);
-    // We expect the `0` case to have been handled in the constant folding pass.
-    DCHECK_NE(factor, 0);
-    if (IsPowerOfTwo(factor)) {
+    // Even though constant propagation also takes care of the zero case, other
+    // optimizations can lead to having a zero multiplication.
+    if (factor == 0) {
+      // Replace code looking like
+      //    MUL dst, src, 0
+      // with
+      //    0
+      instruction->ReplaceWith(input_cst);
+      instruction->GetBlock()->RemoveInstruction(instruction);
+    } else if (IsPowerOfTwo(factor)) {
       // Replace code looking like
       //    MUL dst, src, pow_of_2
       // with