From patchwork Thu Sep 27 01:55:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187256 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 DE24B2C008F for ; Thu, 27 Sep 2012 12:03:31 +1000 (EST) Received: from localhost ([::1]:36628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH3L9-0002pV-4h for incoming@patchwork.ozlabs.org; Wed, 26 Sep 2012 21:56:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH3KV-00012E-NQ for qemu-devel@nongnu.org; Wed, 26 Sep 2012 21:55:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TH3KU-0005m8-N5 for qemu-devel@nongnu.org; Wed, 26 Sep 2012 21:55:55 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:43496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH3KU-0005kA-HH for qemu-devel@nongnu.org; Wed, 26 Sep 2012 21:55:54 -0400 Received: by dadn15 with SMTP id n15so256012dad.4 for ; Wed, 26 Sep 2012 18:55:53 -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=4o2fiKxmacIVlI1cTacxfBRnAfyD4EHBp2anr8xXh/E=; b=mdzzpmAutJkISZFik8Ebg14JjYL6ci9ZkTwI+gQ2hOJA4q5VQf69VccntYUPDsKSXR slrk04afetukJTdiTBP25iBkoHddi3OsAtE4dLZrJJ71dzCw6n1K0VcTb4uxB8w0J/ny 5YwTr9wYkuQW29EbII7BSr+7hpLIPWIFqBFDGtE3NPWtYYOW4uKciD3Wn5FY+Ps5bcrs qCypkCD8UJVfqdkQBRIZwnhaPlD7a0rvb9uhz0DDxO88gcA9Epl6+fAowfMiTEEt4LJE gSKOI799BoGsTF3T0m0hIeEhuFfNxb4yFK4TZckFS0RGZCGdggwiFvpOHt18TUhfe9N7 PEpQ== Received: by 10.68.237.38 with SMTP id uz6mr7477150pbc.23.1348710953648; Wed, 26 Sep 2012 18:55:53 -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.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 18:55:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2012 18:55:33 -0700 Message-Id: <1348710942-3040-4-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.210.45 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 03/12] tcg-sparc: Fix setcond2 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 Like brcond2, use tcg_high_cond. Use movcc instead of branches. Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index c10e3b1..9d4b11a 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -337,7 +337,9 @@ static void tcg_out_arithc(TCGContext *s, int rd, int rs1, static inline void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { - tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); + if (ret != arg) { + tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); + } } static inline void tcg_out_sethi(TCGContext *s, int ret, uint32_t arg) @@ -671,33 +673,29 @@ static void tcg_out_setcond2_i32(TCGContext *s, TCGCond cond, TCGArg ret, TCGArg bl, int blconst, TCGArg bh, int bhconst) { - int lab; + int tmp = TCG_REG_T1; + + /* Note that the low parts are fully consumed before tmp is set. */ + if (ret != ah && (bhconst || ret != bh)) { + tmp = ret; + } switch (cond) { case TCG_COND_EQ: - tcg_out_setcond_i32(s, TCG_COND_EQ, TCG_REG_T1, al, bl, blconst); - tcg_out_setcond_i32(s, TCG_COND_EQ, ret, ah, bh, bhconst); - tcg_out_arith(s, ret, ret, TCG_REG_T1, ARITH_AND); - break; - case TCG_COND_NE: - tcg_out_setcond_i32(s, TCG_COND_NE, TCG_REG_T1, al, al, blconst); - tcg_out_setcond_i32(s, TCG_COND_NE, ret, ah, bh, bhconst); - tcg_out_arith(s, ret, ret, TCG_REG_T1, ARITH_OR); + tcg_out_setcond_i32(s, cond, tmp, al, bl, blconst); + tcg_out_cmp(s, ah, bh, bhconst); + tcg_out_mov(s, TCG_TYPE_I32, ret, tmp); + tcg_out_movcc(s, TCG_COND_NE, MOVCC_ICC, ret, cond == TCG_COND_NE, 1); break; default: - lab = gen_new_label(); - + /* <= : ah < bh | (ah == bh && al <= bl) */ + tcg_out_setcond_i32(s, tcg_unsigned_cond(cond), tmp, al, bl, blconst); tcg_out_cmp(s, ah, bh, bhconst); - tcg_out_branch_i32(s, INSN_COND(tcg_cond_to_bcond[cond], 1), lab); - tcg_out_movi_imm13(s, ret, 1); - tcg_out_branch_i32(s, INSN_COND(COND_NE, 1), lab); - tcg_out_movi_imm13(s, ret, 0); - - tcg_out_setcond_i32(s, tcg_unsigned_cond(cond), ret, al, bl, blconst); - - tcg_out_label(s, lab, s->code_ptr); + tcg_out_mov(s, TCG_TYPE_I32, ret, tmp); + tcg_out_movcc(s, TCG_COND_NE, MOVCC_ICC, ret, 0, 1); + tcg_out_movcc(s, tcg_high_cond(cond), MOVCC_ICC, ret, 1, 1); break; } }