ART: GenLongArith has to clobber same operands for 2-op instr
When we generate code for 'add-long/2addr v4, v4' and v4 is in
memory, we load v4 in a physical register, do operation and
store result in memory. After that, we should clobber the
physical register because it is not valid anymore.
Change-Id: I80903a831040bbfdf8a07810b6b2e8090fe1158c
Signed-off-by: nikolay serdjuk <nikolay.y.serdjuk@intel.com>
diff --git a/compiler/dex/quick/x86/int_x86.cc b/compiler/dex/quick/x86/int_x86.cc
index 3f501b4..3695c5a 100755
--- a/compiler/dex/quick/x86/int_x86.cc
+++ b/compiler/dex/quick/x86/int_x86.cc
@@ -1898,6 +1898,16 @@
AnnotateDalvikRegAccess(lir, (displacement + HIWORD_OFFSET) >> 2,
false /* is_load */, true /* is64bit */);
}
+
+ int v_src_reg = mir_graph_->SRegToVReg(rl_src.s_reg_low);
+ int v_dst_reg = mir_graph_->SRegToVReg(rl_dest.s_reg_low);
+
+ // If the left operand is in memory and the right operand is in a register
+ // and both belong to the same dalvik register then we should clobber the
+ // right one because it doesn't hold valid data anymore.
+ if (v_src_reg == v_dst_reg) {
+ Clobber(rl_src.reg);
+ }
}
void X86Mir2Lir::GenLongArith(RegLocation rl_dest, RegLocation rl_src1,