[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/39] tcg/sparc64: Hoist read of tcg_cond_to_rcond
From: |
Richard Henderson |
Subject: |
[PULL 28/39] tcg/sparc64: Hoist read of tcg_cond_to_rcond |
Date: |
Mon, 5 Feb 2024 07:40:41 +1000 |
Use a non-zero value here (an illegal encoding) as a better
condition than is_unsigned_cond for when MOVR/BPR is usable.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/sparc64/tcg-target.c.inc | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc
index ac86b92b75..e16b25e309 100644
--- a/tcg/sparc64/tcg-target.c.inc
+++ b/tcg/sparc64/tcg-target.c.inc
@@ -620,7 +620,7 @@ static const uint8_t tcg_cond_to_bcond[] = {
[TCG_COND_GTU] = COND_GU,
};
-static const uint8_t tcg_cond_to_rcond[] = {
+static const uint8_t tcg_cond_to_rcond[16] = {
[TCG_COND_EQ] = RCOND_Z,
[TCG_COND_NE] = RCOND_NZ,
[TCG_COND_LT] = RCOND_LZ,
@@ -679,7 +679,8 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond,
TCGReg arg1,
int32_t arg2, int const_arg2, TCGLabel *l)
{
/* For 64-bit signed comparisons vs zero, we can avoid the compare. */
- if (arg2 == 0 && !is_unsigned_cond(cond)) {
+ int rcond = tcg_cond_to_rcond[cond];
+ if (arg2 == 0 && rcond) {
int off16 = 0;
if (l->has_value) {
@@ -688,7 +689,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond,
TCGReg arg1,
tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP16, l, 0);
}
tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1)
- | INSN_COND(tcg_cond_to_rcond[cond]) | off16);
+ | INSN_COND(rcond) | off16);
} else {
tcg_out_cmp(s, arg1, arg2, const_arg2);
tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l);
@@ -696,11 +697,10 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond
cond, TCGReg arg1,
tcg_out_nop(s);
}
-static void tcg_out_movr(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1,
+static void tcg_out_movr(TCGContext *s, int rcond, TCGReg ret, TCGReg c1,
int32_t v1, int v1const)
{
- tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1)
- | (tcg_cond_to_rcond[cond] << 10)
+ tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) | (rcond << 10)
| (v1const ? INSN_IMM10(v1) : INSN_RS2(v1)));
}
@@ -711,9 +711,9 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond
cond, TCGReg ret,
/* For 64-bit signed comparisons vs zero, we can avoid the compare.
Note that the immediate range is one bit smaller, so we must check
for that as well. */
- if (c2 == 0 && !is_unsigned_cond(cond)
- && (!v1const || check_fit_i32(v1, 10))) {
- tcg_out_movr(s, cond, ret, c1, v1, v1const);
+ int rcond = tcg_cond_to_rcond[cond];
+ if (c2 == 0 && rcond && (!v1const || check_fit_i32(v1, 10))) {
+ tcg_out_movr(s, rcond, ret, c1, v1, v1const);
} else {
tcg_out_cmp(s, c1, c2, c2const);
tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const);
@@ -788,6 +788,8 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond
cond, TCGReg ret,
static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret,
TCGReg c1, int32_t c2, int c2const, bool neg)
{
+ int rcond;
+
if (use_vis3_instructions && !neg) {
switch (cond) {
case TCG_COND_NE:
@@ -807,9 +809,10 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond
cond, TCGReg ret,
/* For 64-bit signed comparisons vs zero, we can avoid the compare
if the input does not overlap the output. */
- if (c2 == 0 && !is_unsigned_cond(cond) && c1 != ret) {
+ rcond = tcg_cond_to_rcond[cond];
+ if (c2 == 0 && rcond && c1 != ret) {
tcg_out_movi_s13(s, ret, 0);
- tcg_out_movr(s, cond, ret, c1, neg ? -1 : 1, 1);
+ tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1);
} else {
tcg_out_cmp(s, c1, c2, c2const);
tcg_out_movi_s13(s, ret, 0);
--
2.34.1
- [PULL 21/39] tcg/arm: Split out tcg_out_cmp(), (continued)
- [PULL 21/39] tcg/arm: Split out tcg_out_cmp(), Richard Henderson, 2024/02/04
- [PULL 15/39] target/s390x: Improve general case of disas_jcc, Richard Henderson, 2024/02/04
- [PULL 22/39] tcg/arm: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2024/02/04
- [PULL 23/39] tcg/i386: Pass x86 condition codes to tcg_out_cmov, Richard Henderson, 2024/02/04
- [PULL 24/39] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp, Richard Henderson, 2024/02/04
- [PULL 26/39] tcg/i386: Improve TSTNE/TESTEQ vs powers of two, Richard Henderson, 2024/02/04
- [PULL 30/39] tcg/sparc64: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2024/02/04
- [PULL 31/39] tcg/ppc: Sink tcg_to_bc usage into tcg_out_bc, Richard Henderson, 2024/02/04
- [PULL 27/39] tcg/i386: Use TEST r,r to test 8/16/32 bits, Richard Henderson, 2024/02/04
- [PULL 25/39] tcg/i386: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2024/02/04
- [PULL 28/39] tcg/sparc64: Hoist read of tcg_cond_to_rcond,
Richard Henderson <=
- [PULL 29/39] tcg/sparc64: Pass TCGCond to tcg_out_cmp, Richard Henderson, 2024/02/04
- [PULL 32/39] tcg/ppc: Use cr0 in tcg_to_bc and tcg_to_isel, Richard Henderson, 2024/02/04
- [PULL 33/39] tcg/ppc: Tidy up tcg_target_const_match, Richard Henderson, 2024/02/04
- [PULL 34/39] tcg/ppc: Add TCG_CT_CONST_CMP, Richard Henderson, 2024/02/04
- [PULL 35/39] tcg/ppc: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2024/02/04
- [PULL 36/39] tcg/s390x: Split constraint A into J+U, Richard Henderson, 2024/02/04
- [PULL 37/39] tcg/s390x: Add TCG_CT_CONST_CMP, Richard Henderson, 2024/02/04
- [PULL 38/39] tcg/s390x: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2024/02/04
- [PULL 39/39] tcg/tci: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2024/02/04
- Re: [PULL 00/39] tcg patch queue, Peter Maydell, 2024/02/05