]> git.proxmox.com Git - qemu.git/commitdiff
tcg-ppc64: Fold constant call address into descriptor load
authorRichard Henderson <rth@twiddle.net>
Sat, 31 Aug 2013 13:13:49 +0000 (06:13 -0700)
committerRichard Henderson <rth@twiddle.net>
Wed, 25 Sep 2013 14:46:32 +0000 (07:46 -0700)
Eliminates one insn per call:

 :  lis     r2,4165
-:  ori     r2,r2,59616
-:  ld      r0,0(r2)
+:  ld      r0,-5920(r2)
 :  mtctr   r0
-:  ld      r2,8(r2)
+:  ld      r2,-5912(r2)
 :  bctrl

Signed-off-by: Richard Henderson <rth@twiddle.net>
tcg/ppc64/tcg-target.c

index 5ac62bf40d88df8fb893131dacd12414655db158..8eb04060e65f82a65091466e47d57b4ce1d5dcef 100644 (file)
@@ -713,16 +713,24 @@ static void tcg_out_call(TCGContext *s, tcg_target_long arg, int const_arg)
         tcg_out32(s, BCLR | BO_ALWAYS | LK);
     }
 #else
-    int reg = arg;
+    TCGReg reg = arg;
+    int ofs = 0;
 
     if (const_arg) {
+        /* Fold the low bits of the constant into the addresses below.  */
+        ofs = (int16_t)arg;
+        if (ofs + 8 < 0x8000) {
+            arg -= ofs;
+        } else {
+            ofs = 0;
+        }
         reg = TCG_REG_R2;
         tcg_out_movi(s, TCG_TYPE_I64, reg, arg);
     }
 
-    tcg_out32(s, LD | TAI(TCG_REG_R0, reg, 0));
+    tcg_out32(s, LD | TAI(TCG_REG_R0, reg, ofs));
     tcg_out32(s, MTSPR | RA(TCG_REG_R0) | CTR);
-    tcg_out32(s, LD | TAI(TCG_REG_R2, reg, 8));
+    tcg_out32(s, LD | TAI(TCG_REG_R2, reg, ofs + 8));
     tcg_out32(s, BCCTR | BO_ALWAYS | LK);
 #endif
 }