* src/vm/jit/mips/emit.c (emit_copy): Eliminate register move if one
authortwisti <none@none>
Thu, 7 Sep 2006 10:59:56 +0000 (10:59 +0000)
committertwisti <none@none>
Thu, 7 Sep 2006 10:59:56 +0000 (10:59 +0000)
of the variables resides in memory.

--HG--
branch : new_instruction_format

src/vm/jit/mips/emit.c

index e8becb99ff313a7dc9c3f6b9ae4a4f86d4310f3c..55d12350bbdea1b16dce38b8ed9bc59105ed48ce 100644 (file)
@@ -196,7 +196,7 @@ void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
 
 /* emit_copy *******************************************************************
 
-   XXX
+   Generates a register/memory to register/memory copy.
 
 *******************************************************************************/
 
@@ -213,8 +213,19 @@ void emit_copy(jitdata *jd, instruction *iptr, stackptr src, stackptr dst)
 
        if ((src->regoff != dst->regoff) ||
                ((src->flags ^ dst->flags) & INMEMORY)) {
-               d = codegen_reg_of_var(rd, iptr->opc, dst, REG_IFTMP);
-               s1 = emit_load(jd, iptr, src, d);
+
+               /* If one of the variables resides in memory, we can eliminate
+                  the register move from/to the temporary register with the
+                  order of getting the destination register and the load. */
+
+               if (IS_INMEMORY(src->flags)) {
+                       d = codegen_reg_of_var(rd, iptr->opc, dst, REG_IFTMP);
+                       s1 = emit_load(jd, iptr, src, d);
+               }
+               else {
+                       s1 = emit_load(jd, iptr, src, REG_IFTMP);
+                       d = codegen_reg_of_var(rd, iptr->opc, dst, s1);
+               }
 
                if (s1 != d) {
                        if (IS_FLT_DBL_TYPE(src->type)) {