From patchwork Tue Mar 5 00:32:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 224864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CFDB82C0336 for ; Tue, 5 Mar 2013 11:35:23 +1100 (EST) Received: from localhost ([::1]:35499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCfqk-0007lo-0y for incoming@patchwork.ozlabs.org; Mon, 04 Mar 2013 19:35:22 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCfow-0005LF-UX for qemu-devel@nongnu.org; Mon, 04 Mar 2013 19:33:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCfou-00046d-LA for qemu-devel@nongnu.org; Mon, 04 Mar 2013 19:33:30 -0500 Received: from mail-ie0-x22f.google.com ([2607:f8b0:4001:c03::22f]:65411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCfou-00046Z-Hh for qemu-devel@nongnu.org; Mon, 04 Mar 2013 19:33:28 -0500 Received: by mail-ie0-f175.google.com with SMTP id c12so7068699ieb.34 for ; Mon, 04 Mar 2013 16:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=d1jA/HbQOiTOIEkU4iJU2YZDm1brQ3VqFq0psgLeNfc=; b=JgZGjA84tLMpgR+SNBScG1v1486Fi80yQh/MsPB/a5dkPXvVI3vrO0Q8XpN9f45/dj MnXo6LQl/e0x3HZQGseIv4MRXP4vDdmWVw2vzh9sGkwINkw03kKgKe41cDTnXzak42yW UjB4bnDLF4RA65M0RdewUDBShBRUQr+cSTZic8gEcuSGfa3QfF7XGf/gY4zuBbToQLgJ CmDQ71k+McRkQG+Z+SoRszhQCWarnbaFfEyR3oDkvZRTVRNvxgv/OnMskhJ+3+mKlZ4R 4hTqede7c6U9b9RTLHOaX7wcG4QUkZ3R0mySUNpMMhYyUPHTspckNS0UVOjiSaWhpS/Q w2+g== X-Received: by 10.50.135.8 with SMTP id po8mr4233511igb.41.1362443608109; Mon, 04 Mar 2013 16:33:28 -0800 (PST) Received: from pebble.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id ih1sm12171205igc.3.2013.03.04.16.33.26 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 04 Mar 2013 16:33:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 4 Mar 2013 16:32:50 -0800 Message-Id: <1362443590-28191-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1362443590-28191-1-git-send-email-rth@twiddle.net> References: <1362443590-28191-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::22f Cc: av1474@comtv.ru Subject: [Qemu-devel] [PATCH v2 07/27] tcg-ppc64: Cleanup tcg_out_movi X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The test for using movi32 was sub-optimal for TCG_TYPE_I32, comparing a signed 32-bit quantity against an unsigned 32-bit quantity. When possible, use addi+oris for 32-bit unsigned constants. Otherwise, standardize on addi+oris+ori instead of addis+ori+rldicl. Signed-off-by: Richard Henderson Reviewed-by: Aurelien Jarno --- tcg/ppc64/tcg-target.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index 82e1da7..a4951c5 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -477,29 +477,25 @@ static void tcg_out_movi32(TCGContext *s, TCGReg ret, int32_t arg) } } -static void tcg_out_movi (TCGContext *s, TCGType type, - TCGReg ret, tcg_target_long arg) +static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, + tcg_target_long arg) { - int32_t arg32 = arg; - arg = type == TCG_TYPE_I32 ? arg & 0xffffffff : arg; - - if (arg == arg32) { - tcg_out_movi32 (s, ret, arg32); - } - else { - if ((uint64_t) arg >> 32) { - uint16_t h16 = arg >> 16; - uint16_t l16 = arg; - - tcg_out_movi32 (s, ret, arg >> 32); + if (type == TCG_TYPE_I32 || arg == (int32_t)arg) { + tcg_out_movi32(s, ret, arg); + } else if (arg == (uint32_t)arg && !(arg & 0x8000)) { + tcg_out32(s, ADDI | RT(ret) | RA(0) | (arg & 0xffff)); + tcg_out32(s, ORIS | RT(ret) | RA(ret) | ((arg >> 16) & 0xffff)); + } else { + int32_t high = arg >> 32; + tcg_out_movi32(s, ret, high); + if (high) { tcg_out_shli64(s, ret, ret, 32); - if (h16) tcg_out32 (s, ORIS | RS (ret) | RA (ret) | h16); - if (l16) tcg_out32 (s, ORI | RS (ret) | RA (ret) | l16); } - else { - tcg_out_movi32 (s, ret, arg32); - if (arg32 < 0) - tcg_out_ext32u(s, ret, ret); + if (arg & 0xffff0000) { + tcg_out32(s, ORIS | RS(ret) | RA(ret) | ((arg >> 16) & 0xffff)); + } + if (arg & 0xffff) { + tcg_out32(s, ORI | RS(ret) | RA(ret) | (arg & 0xffff)); } } }