diff mbox

[for-next,05/15] tcg-ppc64: Look through the function descriptor when profitable

Message ID 1375727330-30515-6-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Aug. 5, 2013, 6:28 p.m. UTC
Loading 32-bit immediates instead of memory will be faster.
Don't attempt to generate full 64-bit immediates.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/ppc64/tcg-target.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
index ddc9581..2563253 100644
--- a/tcg/ppc64/tcg-target.c
+++ b/tcg/ppc64/tcg-target.c
@@ -722,6 +722,17 @@  static void tcg_out_call(TCGContext *s, tcg_target_long arg,
 #else
     TCGReg reg = arg;
     if (const_arg) {
+        uintptr_t tgt = ((uintptr_t *)arg)[0];
+        uintptr_t toc = ((uintptr_t *)arg)[1];
+
+        /* Look through the function descriptor, if profitable.  */
+        if (tgt == (int32_t)tgt && toc == (int32_t)toc) {
+            tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, toc);
+            tcg_out_b(s, lk, tgt);
+            return;
+        }
+
+        /* Avoid generating two full 64-bit constants.  */
         reg = TCG_REG_R2;
         tcg_out_movi(s, TCG_TYPE_I64, reg, arg);
     }