From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoEHb-0003oN-Vt for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoEHW-0001RS-0G for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:51 -0400 Received: from mail-pb0-x236.google.com ([2607:f8b0:400e:c01::236]:62866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoEHV-0001PF-Nm for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:45 -0400 Received: by mail-pb0-f54.google.com with SMTP id jt11so5526523pbb.41 for ; Sat, 24 May 2014 08:54:44 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Sat, 24 May 2014 08:53:58 -0700 Message-Id: <1400946841-21079-22-git-send-email-rth@twiddle.net> In-Reply-To: <1400946841-21079-1-git-send-email-rth@twiddle.net> References: <1400946841-21079-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL 21/24] tcg-mips: Improve setcond eq/ne vs zeros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org The original code results in one too many insns per zero present in the input. And since comparing 64-bit numbers vs zero is common... Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 1429ec7..ccf262b 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -701,6 +701,40 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out_nop(s); } +static TCGReg tcg_out_reduce_eq2(TCGContext *s, TCGReg tmp0, TCGReg tmp1, + TCGReg al, TCGReg ah, + TCGReg bl, TCGReg bh) +{ + /* Merge highpart comparison into AH. */ + if (bh != 0) { + if (ah != 0) { + tcg_out_opc_reg(s, OPC_XOR, tmp0, ah, bh); + ah = tmp0; + } else { + ah = bh; + } + } + /* Merge lowpart comparison into AL. */ + if (bl != 0) { + if (al != 0) { + tcg_out_opc_reg(s, OPC_XOR, tmp1, al, bl); + al = tmp1; + } else { + al = bl; + } + } + /* Merge high and low part comparisons into AL. */ + if (ah != 0) { + if (al != 0) { + tcg_out_opc_reg(s, OPC_OR, tmp0, ah, al); + al = tmp0; + } else { + al = ah; + } + } + return al; +} + static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg al, TCGReg ah, TCGReg bl, TCGReg bh) { @@ -716,10 +750,8 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, switch (cond) { case TCG_COND_EQ: case TCG_COND_NE: - tcg_out_setcond(s, cond, tmp0, ah, bh); - tcg_out_setcond(s, cond, ret, al, bl); - tcg_out_opc_reg(s, (cond == TCG_COND_EQ ? OPC_AND : OPC_OR), - ret, ret, tmp0); + tmp1 = tcg_out_reduce_eq2(s, tmp0, tmp1, al, ah, bl, bh); + tcg_out_setcond(s, cond, ret, tmp1, TCG_REG_ZERO); break; default: -- 1.9.0