From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGAKJ-0000Cr-2m for qemu-devel@nongnu.org; Sun, 01 Sep 2013 12:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGAKD-0006wi-3M for qemu-devel@nongnu.org; Sun, 01 Sep 2013 12:16:35 -0400 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]:55829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGAKC-0006wa-Rj for qemu-devel@nongnu.org; Sun, 01 Sep 2013 12:16:29 -0400 Received: by mail-pb0-f52.google.com with SMTP id wz12so3794108pbc.11 for ; Sun, 01 Sep 2013 09:16:27 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Sun, 1 Sep 2013 09:16:06 -0700 Message-Id: <1378052173-3579-8-git-send-email-rth@twiddle.net> In-Reply-To: <1378052173-3579-1-git-send-email-rth@twiddle.net> References: <1378052173-3579-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 07/14] tcg-ppc64: Fold constant call address into descriptor load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Vassili Karpov (malc)" , aurelien@aurel32.net, Richard Henderson 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 --- tcg/ppc64/tcg-target.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index e631991..033518c 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -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 } -- 1.8.3.1