All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: lucas.castro@eldorado.org.br, qemu-devel@nongnu.org,
	groug@kaod.org, luis.pires@eldorado.org.br, qemu-ppc@nongnu.org,
	matheus.ferst@eldorado.org.br
Subject: Re: [PATCH v2 07/34] target/ppc: Implement cntlzdm
Date: Mon, 1 Nov 2021 11:16:59 +1100	[thread overview]
Message-ID: <YX8x+1qf3V8RFFSB@yekko> (raw)
In-Reply-To: <65bd3052-fbe9-33ff-585c-b5259ebd46e0@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3058 bytes --]

On Sat, Oct 30, 2021 at 02:17:07PM -0700, Richard Henderson wrote:
> On 10/29/21 1:23 PM, matheus.ferst@eldorado.org.br wrote:
> > From: Luis Pires <luis.pires@eldorado.org.br>
> > 
> > Implement the following PowerISA v3.1 instruction:
> > cntlzdm: Count Leading Zeros Doubleword Under Bit Mask
> > 
> > Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> > Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
> > Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> > ---
> > v2:
> > - Inline implementation of cntlzdm
> > ---
> >   target/ppc/insn32.decode                   |  1 +
> >   target/ppc/translate/fixedpoint-impl.c.inc | 36 ++++++++++++++++++++++
> >   2 files changed, 37 insertions(+)
> > 
> > diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> > index 9cb9fc00b8..221cb00dd6 100644
> > --- a/target/ppc/insn32.decode
> > +++ b/target/ppc/insn32.decode
> > @@ -203,6 +203,7 @@ ADDPCIS         010011 ..... ..... .......... 00010 .   @DX
> >   ## Fixed-Point Logical Instructions
> >   CFUGED          011111 ..... ..... ..... 0011011100 -   @X
> > +CNTLZDM         011111 ..... ..... ..... 0000111011 -   @X
> >   ### Float-Point Load Instructions
> > diff --git a/target/ppc/translate/fixedpoint-impl.c.inc b/target/ppc/translate/fixedpoint-impl.c.inc
> > index 0d9c6e0996..c9e9ae35df 100644
> > --- a/target/ppc/translate/fixedpoint-impl.c.inc
> > +++ b/target/ppc/translate/fixedpoint-impl.c.inc
> > @@ -413,3 +413,39 @@ static bool trans_CFUGED(DisasContext *ctx, arg_X *a)
> >   #endif
> >       return true;
> >   }
> > +
> > +#if defined(TARGET_PPC64)
> > +static void do_cntlzdm(TCGv_i64 dst, TCGv_i64 src, TCGv_i64 mask)
> > +{
> > +    TCGv_i64 tmp;
> > +    TCGLabel *l1;
> > +
> > +    tmp = tcg_temp_local_new_i64();
> > +    l1 = gen_new_label();
> > +
> > +    tcg_gen_and_i64(tmp, src, mask);
> > +    tcg_gen_clzi_i64(tmp, tmp, 64);
> > +
> > +    tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, l1);
> > +
> > +    tcg_gen_subfi_i64(tmp, 64, tmp);
> > +    tcg_gen_shr_i64(tmp, mask, tmp);
> > +    tcg_gen_ctpop_i64(tmp, tmp);
> > +
> > +    gen_set_label(l1);
> > +
> > +    tcg_gen_mov_i64(dst, tmp);
> 
> This works, but a form without brcond would be better (due to how poorly tcg
> handles basic blocks).
> 
> How about
> 
>     tcg_gen_clzi_i64(tmp, tmp, 0);
> 
>     tcg_gen_xori_i64(tmp, tmp, 63);
>     tcg_gen_shr_i64(tmp, mask, tmp);
>     tcg_gen_shri_i64(tmp, tmp, 1);
> 
>     tcg_gen_ctpop_i64(dst, tmp);

I've applied this to ppc-for-6.2.  You can make this improvement as a
followup if you want.

> 
> The middle 3 operations perform a shift between [1-64], such that we are assured of 0 for 64.
> 
> Either way,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> 
> r~
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-11-01  1:33 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 20:23 [PATCH v2 00/34] PowerISA v3.1 instruction batch matheus.ferst
2021-10-29 20:23 ` [PATCH v2 01/34] target/ppc: introduce do_ea_calc matheus.ferst
2021-10-29 20:23 ` [PATCH v2 02/34] target/ppc: move resolve_PLS_D to translate.c matheus.ferst
2021-10-29 20:23 ` [PATCH v2 03/34] target/ppc: Move load and store floating point instructions to decodetree matheus.ferst
2021-11-09 13:43   ` Mark Cave-Ayland
2021-11-09 17:32     ` Matheus K. Ferst
2021-11-09 18:24       ` Mark Cave-Ayland
2021-10-29 20:23 ` [PATCH v2 04/34] target/ppc: Implement PLFS, PLFD, PSTFS and PSTFD instructions matheus.ferst
2021-10-29 20:23 ` [PATCH v2 05/34] target/ppc: Move LQ and STQ to decodetree matheus.ferst
2021-10-29 20:23 ` [PATCH v2 06/34] target/ppc: Implement PLQ and PSTQ matheus.ferst
2021-10-29 20:23 ` [PATCH v2 07/34] target/ppc: Implement cntlzdm matheus.ferst
2021-10-30 21:17   ` Richard Henderson
2021-11-01  0:16     ` David Gibson [this message]
2021-11-04 11:37     ` Matheus K. Ferst
2021-10-29 20:23 ` [PATCH v2 08/34] target/ppc: Implement cnttzdm matheus.ferst
2021-10-30 21:17   ` Richard Henderson
2021-10-29 20:23 ` [PATCH v2 09/34] target/ppc: Implement pdepd instruction matheus.ferst
2021-10-29 20:24 ` [PATCH v2 10/34] target/ppc: Implement pextd instruction matheus.ferst
2021-10-29 20:24 ` [PATCH v2 11/34] target/ppc: Move vcfuged to vmx-impl.c.inc matheus.ferst
2021-11-01  0:20   ` David Gibson
2021-10-29 20:24 ` [PATCH v2 12/34] target/ppc: Implement vclzdm/vctzdm instructions matheus.ferst
2021-10-30 21:34   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 13/34] target/ppc: Implement vpdepd/vpextd instruction matheus.ferst
2021-10-29 20:24 ` [PATCH v2 14/34] target/ppc: Implement vsldbi/vsrdbi instructions matheus.ferst
2021-10-30 21:42   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 15/34] target/ppc: Implement Vector Insert from GPR using GPR index insns matheus.ferst
2021-10-30 22:26   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 16/34] target/ppc: Implement Vector Insert Word from GPR using Immediate insns matheus.ferst
2021-10-30 22:27   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 17/34] target/ppc: Implement Vector Insert from VSR using GPR index insns matheus.ferst
2021-10-29 20:24 ` [PATCH v2 18/34] target/ppc: Move vinsertb/vinserth/vinsertw/vinsertd to decodetree matheus.ferst
2021-10-29 20:24 ` [PATCH v2 19/34] target/ppc: Implement Vector Extract Double to VSR using GPR index insns matheus.ferst
2021-10-30 22:29   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 20/34] target/ppc: Introduce REQUIRE_VSX macro matheus.ferst
2021-10-29 20:24 ` [PATCH v2 21/34] target/ppc: receive high/low as argument in get/set_cpu_vsr matheus.ferst
2021-10-30 22:31   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 22/34] target/ppc: moved stxv and lxv from legacy to decodtree matheus.ferst
2021-10-30 22:32   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 23/34] target/ppc: moved stxvx and lxvx " matheus.ferst
2021-10-29 20:24 ` [PATCH v2 24/34] target/ppc: added the instructions LXVP and STXVP matheus.ferst
2021-10-30 23:13   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 25/34] target/ppc: added the instructions LXVPX and STXVPX matheus.ferst
2021-10-29 20:24 ` [PATCH v2 26/34] target/ppc: added the instructions PLXV and PSTXV matheus.ferst
2021-10-29 20:24 ` [PATCH v2 27/34] target/ppc: added the instructions PLXVP and PSTXVP matheus.ferst
2021-10-29 20:24 ` [PATCH v2 28/34] target/ppc: moved XXSPLTW to using decodetree matheus.ferst
2021-10-29 20:24 ` [PATCH v2 29/34] target/ppc: moved XXSPLTIB " matheus.ferst
2021-10-29 20:24 ` [PATCH v2 30/34] target/ppc: implemented XXSPLTI32DX matheus.ferst
2021-10-30 23:27   ` Richard Henderson
2021-10-29 20:24 ` [PATCH v2 31/34] target/ppc: Implemented XXSPLTIW using decodetree matheus.ferst
2021-10-29 20:24 ` [PATCH v2 32/34] target/ppc: implemented XXSPLTIDP instruction matheus.ferst
2021-10-29 20:24 ` [PATCH v2 33/34] target/ppc: Implement xxblendvb/xxblendvh/xxblendvw/xxblendvd instructions matheus.ferst
2021-10-29 20:24 ` [PATCH v2 34/34] target/ppc: Implement lxvkq instruction matheus.ferst
2021-11-01  0:13 ` [PATCH v2 00/34] PowerISA v3.1 instruction batch David Gibson
2021-11-01  0:22   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YX8x+1qf3V8RFFSB@yekko \
    --to=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=lucas.castro@eldorado.org.br \
    --cc=luis.pires@eldorado.org.br \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.