[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 08/24] target/sparc: Use tcg_gen_movcond_i64 in gen_edge
From: |
Peter Maydell |
Subject: |
Re: [PATCH 08/24] target/sparc: Use tcg_gen_movcond_i64 in gen_edge |
Date: |
Thu, 10 Aug 2023 17:29:54 +0100 |
On Tue, 8 Aug 2023 at 04:14, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> The setcond + neg + or sequence is a complex method of
> performing a conditional move.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/sparc/translate.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/target/sparc/translate.c b/target/sparc/translate.c
> index bd877a5e4a..fa80a91161 100644
> --- a/target/sparc/translate.c
> +++ b/target/sparc/translate.c
> @@ -2916,7 +2916,7 @@ static void gen_edge(DisasContext *dc, TCGv dst, TCGv
> s1, TCGv s2,
>
> tcg_gen_shr_tl(lo1, tcg_constant_tl(tabl), lo1);
> tcg_gen_shr_tl(lo2, tcg_constant_tl(tabr), lo2);
> - tcg_gen_andi_tl(dst, lo1, omask);
> + tcg_gen_andi_tl(lo1, lo1, omask);
> tcg_gen_andi_tl(lo2, lo2, omask);
>
> amask = -8;
> @@ -2926,18 +2926,9 @@ static void gen_edge(DisasContext *dc, TCGv dst, TCGv
> s1, TCGv s2,
> tcg_gen_andi_tl(s1, s1, amask);
> tcg_gen_andi_tl(s2, s2, amask);
>
> - /* We want to compute
> - dst = (s1 == s2 ? lo1 : lo1 & lo2).
> - We've already done dst = lo1, so this reduces to
> - dst &= (s1 == s2 ? -1 : lo2)
> - Which we perform by
> - lo2 |= -(s1 == s2)
> - dst &= lo2
> - */
> - tcg_gen_setcond_tl(TCG_COND_EQ, lo1, s1, s2);
> - tcg_gen_neg_tl(lo1, lo1);
> - tcg_gen_or_tl(lo2, lo2, lo1);
> - tcg_gen_and_tl(dst, dst, lo2);
> + /* Compute dst = (s1 == s2 ? lo1 : lo1 & lo2). */
> + tcg_gen_and_tl(lo2, lo2, lo1);
> + tcg_gen_movcond_tl(TCG_COND_EQ, dst, s1, s2, lo1, lo2);
> }
I'm glad I didn't have to figure out exactly what this
exciting instruction actually does to review this :-)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
- [PATCH 04/24] target/arm: Use tcg_gen_negsetcond_*, (continued)
- [PATCH 04/24] target/arm: Use tcg_gen_negsetcond_*, Richard Henderson, 2023/08/07
- [PATCH 05/24] target/m68k: Use tcg_gen_negsetcond_*, Richard Henderson, 2023/08/07
- [PATCH 06/24] target/openrisc: Use tcg_gen_negsetcond_*, Richard Henderson, 2023/08/07
- [PATCH 07/24] target/ppc: Use tcg_gen_negsetcond_*, Richard Henderson, 2023/08/07
- [PATCH 08/24] target/sparc: Use tcg_gen_movcond_i64 in gen_edge, Richard Henderson, 2023/08/07
- Re: [PATCH 08/24] target/sparc: Use tcg_gen_movcond_i64 in gen_edge,
Peter Maydell <=
- [PATCH 09/24] target/tricore: Replace gen_cond_w with tcg_gen_negsetcond_tl, Richard Henderson, 2023/08/07
- [PATCH 10/24] tcg/ppc: Implement negsetcond_*, Richard Henderson, 2023/08/07
- [PATCH 11/24] tcg/ppc: Use the Set Boolean Extension, Richard Henderson, 2023/08/07
- [PATCH 12/24] tcg/aarch64: Implement negsetcond_*, Richard Henderson, 2023/08/07