Bug fix for JIT peephole optimization.
Bug: 2520500
Change-Id: I36dbd8b3a6d13c40f9735df4918ab02b5f053b07
diff --git a/vm/compiler/codegen/arm/LocalOptimizations.c b/vm/compiler/codegen/arm/LocalOptimizations.c
index 9f616b8..fbeceef 100644
--- a/vm/compiler/codegen/arm/LocalOptimizations.c
+++ b/vm/compiler/codegen/arm/LocalOptimizations.c
@@ -105,11 +105,13 @@
moveLIR = dvmCompilerRegCopyNoInsert(
cUnit, checkLIR->operands[0], nativeRegId);
/*
- * Insertion is guaranteed to succeed since checkLIR
- * is never the first LIR on the list
+ * Insert the converted checkLIR instruction after the
+ * the original checkLIR since the optimization is
+ * scannng in the top-down order and the new instruction
+ * will need to be checked.
*/
- dvmCompilerInsertLIRBefore((LIR *) checkLIR,
- (LIR *) moveLIR);
+ dvmCompilerInsertLIRAfter((LIR *) checkLIR,
+ (LIR *) moveLIR);
}
checkLIR->isNop = true;
continue;