From patchwork Tue Jul 14 15:45:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 495152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AF02D140770 for ; Wed, 15 Jul 2015 01:48:43 +1000 (AEST) Received: from localhost ([::1]:60207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF2Rl-0005UX-TO for incoming@patchwork.ozlabs.org; Tue, 14 Jul 2015 11:48:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF2Oj-0000KE-DT for qemu-devel@nongnu.org; Tue, 14 Jul 2015 11:45:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZF2Oi-0000bQ-A0 for qemu-devel@nongnu.org; Tue, 14 Jul 2015 11:45:33 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:41421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF2Oi-0000YN-55 for qemu-devel@nongnu.org; Tue, 14 Jul 2015 11:45:32 -0400 Received: from weber.rr44.fr ([2001:bc8:30d7:120:7e05:7ff:fe0d:f152]) by hall.aurel32.net with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1ZF2OZ-0004ds-GL; Tue, 14 Jul 2015 17:45:23 +0200 Received: from aurel32 by weber.rr44.fr with local (Exim 4.85) (envelope-from ) id 1ZF2OY-00028N-P8; Tue, 14 Jul 2015 17:45:22 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Tue, 14 Jul 2015 17:45:17 +0200 Message-Id: <1436888717-8122-3-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436888717-8122-1-git-send-email-aurelien@aurel32.net> References: <1436888717-8122-1-git-send-email-aurelien@aurel32.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:bc8:30d7:100::1 Cc: Leon Alrae , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [Qemu-devel] [PATCH 2/2] target-mips: simplify LWL/LDL mask generation 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 LWL/LDL instructions mask the GPR with a mask depending on the address alignement. It is currently computed by doing: mask = 0x7fffffffffffffffull >> (t1 ^ 63) It's simpler to generate it by doing: mask = (1 << t1) - 1 It uses the same number of TCG instructions, but it avoids a 32/64-bit constant loading which can take a few instructions on RISC hosts. Cc: Leon Alrae Tested-by: Hervé Poussineau Signed-off-by: Aurelien Jarno --- target-mips/translate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index 0ac3bd8..9891209 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -2153,9 +2153,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc, tcg_gen_andi_tl(t0, t0, ~7); tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEQ); tcg_gen_shl_tl(t0, t0, t1); - tcg_gen_xori_tl(t1, t1, 63); - t2 = tcg_const_tl(0x7fffffffffffffffull); - tcg_gen_shr_tl(t2, t2, t1); + t2 = tcg_const_tl(1); + tcg_gen_shl_tl(t2, t2, t1); + tcg_gen_subi_tl(t2, t2, 1); gen_load_gpr(t1, rt); tcg_gen_and_tl(t1, t1, t2); tcg_temp_free(t2); @@ -2246,9 +2246,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc, tcg_gen_andi_tl(t0, t0, ~3); tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEUL); tcg_gen_shl_tl(t0, t0, t1); - tcg_gen_xori_tl(t1, t1, 31); - t2 = tcg_const_tl(0x7fffffffull); - tcg_gen_shr_tl(t2, t2, t1); + t2 = tcg_const_tl(1); + tcg_gen_shl_tl(t2, t2, t1); + tcg_gen_subi_tl(t2, t2, 1); gen_load_gpr(t1, rt); tcg_gen_and_tl(t1, t1, t2); tcg_temp_free(t2);