From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoEHf-0003w6-Nu for qemu-devel@nongnu.org; Sat, 24 May 2014 11:55:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoEHZ-0001ZP-NF for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:55 -0400 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]:38785) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoEHZ-0001Wq-BF for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:49 -0400 Received: by mail-pa0-f44.google.com with SMTP id ld10so5474077pab.31 for ; Sat, 24 May 2014 08:54:48 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Sat, 24 May 2014 08:54:00 -0700 Message-Id: <1400946841-21079-24-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 23/24] tcg-mips: Simplify movcond List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Use the same table to fold comparisons as with setcond. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 66 +++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 0e5ecf4..ad752c4 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -794,65 +794,33 @@ static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGReg al, TCGReg ah, } static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, - TCGArg c1, TCGArg c2, TCGArg v) + TCGReg c1, TCGReg c2, TCGReg v) { + MIPSInsn m_opc = OPC_MOVN; + switch (cond) { case TCG_COND_EQ: - if (c1 == 0) { - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, c2); - } else if (c2 == 0) { - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, c1); - } else { - tcg_out_opc_reg(s, OPC_XOR, TCG_TMP0, c1, c2); - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, TCG_TMP0); - } - break; + m_opc = OPC_MOVZ; + /* FALLTHRU */ case TCG_COND_NE: - if (c1 == 0) { - tcg_out_opc_reg(s, OPC_MOVN, ret, v, c2); - } else if (c2 == 0) { - tcg_out_opc_reg(s, OPC_MOVN, ret, v, c1); - } else { + if (c2 != 0) { tcg_out_opc_reg(s, OPC_XOR, TCG_TMP0, c1, c2); - tcg_out_opc_reg(s, OPC_MOVN, ret, v, TCG_TMP0); + c1 = TCG_TMP0; } break; - case TCG_COND_LT: - tcg_out_opc_reg(s, OPC_SLT, TCG_TMP0, c1, c2); - tcg_out_opc_reg(s, OPC_MOVN, ret, v, TCG_TMP0); - break; - case TCG_COND_LTU: - tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, c1, c2); - tcg_out_opc_reg(s, OPC_MOVN, ret, v, TCG_TMP0); - break; - case TCG_COND_GE: - tcg_out_opc_reg(s, OPC_SLT, TCG_TMP0, c1, c2); - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, TCG_TMP0); - break; - case TCG_COND_GEU: - tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, c1, c2); - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, TCG_TMP0); - break; - case TCG_COND_LE: - tcg_out_opc_reg(s, OPC_SLT, TCG_TMP0, c2, c1); - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, TCG_TMP0); - break; - case TCG_COND_LEU: - tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, c2, c1); - tcg_out_opc_reg(s, OPC_MOVZ, ret, v, TCG_TMP0); - break; - case TCG_COND_GT: - tcg_out_opc_reg(s, OPC_SLT, TCG_TMP0, c2, c1); - tcg_out_opc_reg(s, OPC_MOVN, ret, v, TCG_TMP0); - break; - case TCG_COND_GTU: - tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, c2, c1); - tcg_out_opc_reg(s, OPC_MOVN, ret, v, TCG_TMP0); - break; + default: - tcg_abort(); + /* Minimize code size by prefering a compare not requiring INV. */ + if (mips_cmp_map[cond] & MIPS_CMP_INV) { + cond = tcg_invert_cond(cond); + m_opc = OPC_MOVZ; + } + tcg_out_setcond(s, cond, TCG_TMP0, c1, c2); + c1 = TCG_TMP0; break; } + + tcg_out_opc_reg(s, m_opc, ret, v, c1); } static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) -- 1.9.0