summaryrefslogtreecommitdiff
path: root/tcg
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2014-04-15 22:53:12 -0700
committerRichard Henderson <rth@twiddle.net>2014-05-24 08:47:14 -0700
commit33fac20bb2ae7fe48932bd950a74ff2f7b134b0f (patch)
tree6b885958507dd12eda3934bad3637dba0a740804 /tcg
parent3401fd259e37f08e1333169494bea30ea02a1d63 (diff)
downloadqemu-33fac20bb2ae7fe48932bd950a74ff2f7b134b0f.tar.gz
qemu-33fac20bb2ae7fe48932bd950a74ff2f7b134b0f.tar.bz2
qemu-33fac20bb2ae7fe48932bd950a74ff2f7b134b0f.zip
tcg-mips: Simplify movcond
Use the same table to fold comparisons as with setcond. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'tcg')
-rw-r--r--tcg/mips/tcg-target.c66
1 files changed, 17 insertions, 49 deletions
diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c
index 0e5ecf4974..ad752c43cd 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)