[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 21/24] tcg-mips: Improve setcond eq/ne vs zeros
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 21/24] tcg-mips: Improve setcond eq/ne vs zeros |
Date: |
Wed, 14 May 2014 00:17:38 -0700 |
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...
Signed-off-by: Richard Henderson <address@hidden>
---
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
- [Qemu-devel] [PATCH 08/24] tcg-mips: Convert to new_ldst, (continued)
- [Qemu-devel] [PATCH 08/24] tcg-mips: Convert to new_ldst, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 13/24] tcg-mips: Name the opcode enumeration, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 12/24] tcg-mips: Use EXT for AND on mips32r2, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 14/24] tcg-mips: Fix subtract immediate range, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 15/24] tcg-mips: Hoist args loads, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 16/24] tcg-mips: Improve add2/sub2, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 17/24] tcg-mips: Commonize opcode implementations, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 18/24] tcg-mips: Simplify setcond, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 19/24] tcg-mips: Simplify brcond, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 20/24] tcg-mips: Simplify setcond2, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 21/24] tcg-mips: Improve setcond eq/ne vs zeros,
Richard Henderson <=
- [Qemu-devel] [PATCH 22/24] tcg-mips: Simplify brcond2, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 23/24] tcg-mips: Simplify movcond, Richard Henderson, 2014/05/14
- [Qemu-devel] [PATCH 24/24] tcg-mips: Enable direct chaining of TBs, Richard Henderson, 2014/05/14
- Re: [Qemu-devel] [PATCH 00/24] tcg mips updates, Richard Henderson, 2014/05/23