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

--HG--
branch : new_instruction_format

src/vm/jit/powerpc64/emit.c

index 51c91daef1f7f9bddf4184f01dde3352138779c6..1416748822b794e13fa196fb3184895a913ab08a 100644 (file)
@@ -193,7 +193,7 @@ void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
 
 /* emit_copy *******************************************************************
 
-   XXX
+   Generates a register/memory to register/memory copy.
 
 *******************************************************************************/
 
@@ -211,13 +211,25 @@ 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 (IS_FLT_DBL_TYPE(src->type))
-                       M_FLTMOVE(s1, d);
-               else
-                       M_INTMOVE(s1, d);
+               if (s1 != d) {
+                       if (IS_FLT_DBL_TYPE(src->type))
+                               M_FMOV(s1, d);
+                       else
+                               M_MOV(s1, d);
+               }
 
                emit_store(jd, iptr, dst, d);
        }