From patchwork Thu Sep 27 01:55:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187271 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 762292C00B4 for ; Thu, 27 Sep 2012 13:06:15 +1000 (EST) Received: from localhost ([::1]:36634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH3LB-0002pd-Da for incoming@patchwork.ozlabs.org; Wed, 26 Sep 2012 21:56:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH3KX-00016H-0z for qemu-devel@nongnu.org; Wed, 26 Sep 2012 21:55:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TH3KW-0005pA-2r for qemu-devel@nongnu.org; Wed, 26 Sep 2012 21:55:56 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:50416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH3KV-0005ej-Sy for qemu-devel@nongnu.org; Wed, 26 Sep 2012 21:55:56 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so2797089pbb.4 for ; Wed, 26 Sep 2012 18:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=xAF67tvy9lfaPHlJ54aZ6t7m+jjsf/kuOKIp+sxQdH8=; b=TMxlyPUJPxCn3eJ0VXtLWdYPBFF6oJneE73EHM7GIaNMNS+NDIHLWrmj/dAX0+GPBI bB3S/NDmbNo+z5QMYhhFQWG4nt32Yk51PMVCTHELTBs3SDLyqCqQuFF6fVu5nkQdX+Ku 4lmPiYTL/NCW4kfqh2wWXvFSiVXIcpJLzSZwfh4Zmkzcf7b9qEan98Prc2gIbnT0hRTF eJTBpyxW/r5XeYXKnDtKMqxHDTjXK3d/hUM9d/06GUC2r8HGeZVgEwO/iuxxerq2q3e8 dcFkm1esXsIyjdqXkN3R3L8ud2TMCmFVRNEXl5cfiRGV9C25XIqiwtXEQC91egAKsLAY ekLw== Received: by 10.68.197.9 with SMTP id iq9mr7446217pbc.17.1348710955460; Wed, 26 Sep 2012 18:55:55 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id o1sm2830071pax.21.2012.09.26.18.55.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 18:55:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2012 18:55:35 -0700 Message-Id: <1348710942-3040-6-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348710942-3040-1-git-send-email-rth@twiddle.net> References: <1348710942-3040-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 05/12] tcg-sparc: Fix setcond 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 set of comparisons that can immediately use the carry are LTU/GEU, not LTU/LEU. Don't swap operands when we need a temp register; the register may already be in use from setcond2. Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index e55b792..c3e15b9 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -617,32 +617,37 @@ static void tcg_out_brcond2_i32(TCGContext *s, TCGCond cond, static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGArg ret, TCGArg c1, TCGArg c2, int c2const) { - TCGArg t; - /* For 32-bit comparisons, we can play games with ADDX/SUBX. */ switch (cond) { + case TCG_COND_LTU: + case TCG_COND_GEU: + /* The result of the comparison is in the carry bit. */ + break; + case TCG_COND_EQ: case TCG_COND_NE: + /* For equality, we can transform to inequality vs zero. */ if (c2 != 0) { tcg_out_arithc(s, ret, c1, c2, c2const, ARITH_XOR); } c1 = TCG_REG_G0, c2 = ret, c2const = 0; - cond = (cond == TCG_COND_EQ ? TCG_COND_LEU : TCG_COND_LTU); + cond = (cond == TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU); break; case TCG_COND_GTU: - case TCG_COND_GEU: - if (c2const && c2 != 0) { - tcg_out_movi_imm13(s, TCG_REG_T1, c2); - c2 = TCG_REG_T1; - } - t = c1, c1 = c2, c2 = t, c2const = 0; - cond = tcg_swap_cond(cond); - break; - - case TCG_COND_LTU: case TCG_COND_LEU: - break; + /* If we don't need to load a constant into a register, we can + swap the operands on GTU/LEU. There's no benefit to loading + the constant into a temporary register. */ + if (!c2const || c2 == 0) { + TCGArg t = c1; + c1 = c2; + c2 = t; + c2const = 0; + cond = tcg_swap_cond(cond); + break; + } + /* FALLTHRU */ default: tcg_out_cmp(s, c1, c2, c2const);