From patchwork Thu Apr 4 22:56:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 234002 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 7CE792C00A7 for ; Fri, 5 Apr 2013 10:31:34 +1100 (EST) Received: from localhost ([::1]:60441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNt85-0000wh-9n for incoming@patchwork.ozlabs.org; Thu, 04 Apr 2013 18:59:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNt5j-0005bd-5v for qemu-devel@nongnu.org; Thu, 04 Apr 2013 18:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UNt5b-0001Hy-UU for qemu-devel@nongnu.org; Thu, 04 Apr 2013 18:57:11 -0400 Received: from mail-ob0-x233.google.com ([2607:f8b0:4003:c01::233]:64448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNt5b-0001Hq-LW for qemu-devel@nongnu.org; Thu, 04 Apr 2013 18:57:03 -0400 Received: by mail-ob0-f179.google.com with SMTP id vb8so3150966obc.10 for ; Thu, 04 Apr 2013 15:57:03 -0700 (PDT) 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=Gtc5q6SEL6QHkSRVn3fLhYcyMrgsiwGlXhppfXGjSlI=; b=rL6pG2vcwQ+ivUznkMmBD2J3fVVA/toObU+lRX16bNxcjHK+6O58AmQjodRQXnKuBJ U02KxZJUCUcjGX3xXXCOrCg/5HfO4GaPNZWVqLDyXKKYn5RfibXbRZ3/Koktw/mJ1b1+ XrhJvOaMYne32dh6kUHNhwvFotP0lDZA2RCmo6Jx/jvEudzyZzF4sRS+J9PsetYgFzkl BbJSG7OwrqxR5IQL5ZXBnqkw5bUy62E9784Ce+IHuAFm/JHNRshfPmOn+cmn7lOZ0BIR J3PAeqvw35+pZq2E7ifI3kY5buxvpvyynR3FahwCM1ZaAWd615aLTwSKEjNmJEx95Ric es7Q== X-Received: by 10.60.47.33 with SMTP id a1mr6223341oen.79.1365116222988; Thu, 04 Apr 2013 15:57:02 -0700 (PDT) Received: from pebble.com ([12.236.175.36]) by mx.google.com with ESMTPS id j10sm9227424obg.4.2013.04.04.15.57.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Apr 2013 15:57:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 4 Apr 2013 17:56:02 -0500 Message-Id: <1365116186-19382-10-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1365116186-19382-1-git-send-email-rth@twiddle.net> References: <1365116186-19382-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:4003:c01::233 Cc: av1474@comtv.ru, Aurelien Jarno Subject: [Qemu-devel] [PATCH v4 09/33] 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. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/ppc64/tcg-target.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index 822eb07..c6ff75b 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -480,32 +480,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 | TAI(ret, 0, arg)); + tcg_out32(s, ORIS | SAI(ret, ret, arg >> 16)); + } 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 | SAI(ret, ret, h16)); - } - if (l16) { - tcg_out32(s, ORI | SAI(ret, 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 | SAI(ret, ret, arg >> 16)); + } + if (arg & 0xffff) { + tcg_out32(s, ORI | SAI(ret, ret, arg)); } } }