From: Richard Henderson <richard.henderson@linaro.org>
To: Vladimir Isaev <vladimir.isaev@syntacore.com>,
palmer@dabbelt.com, alistair.francis@wdc.com,
bin.meng@windriver.com, qemu-riscv@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] target/riscv: fix ctzw behavior
Date: Fri, 3 Feb 2023 06:56:00 -1000 [thread overview]
Message-ID: <0078f162-02ca-628e-7695-27944b491144@linaro.org> (raw)
In-Reply-To: <20230203140059.13068-1-vladimir.isaev@syntacore.com>
On 2/3/23 04:00, Vladimir Isaev wrote:
> According to spec, ctzw should work with 32-bit register, not 64.
>
> For example, previous implementation returns 33 for (1<<33) input
> when the new one returns 32.
>
> Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
> ---
> target/riscv/insn_trans/trans_rvb.c.inc | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
> index e2b8329f1e5b..42c6ded13de8 100644
> --- a/target/riscv/insn_trans/trans_rvb.c.inc
> +++ b/target/riscv/insn_trans/trans_rvb.c.inc
> @@ -80,7 +80,14 @@ static void gen_ctz(TCGv ret, TCGv arg1)
>
> static void gen_ctzw(TCGv ret, TCGv arg1)
> {
> - tcg_gen_ctzi_tl(ret, arg1, 32);
> + TCGv_i32 t = tcg_temp_new_i32();
> +
> + tcg_gen_trunc_tl_i32(t, arg1);
> + tcg_gen_ctzi_i32(t, t, 32);
> +
> + tcg_gen_extu_i32_tl(ret, t);
> +
> + tcg_temp_free_i32(t);
This was supposed to be handled by EXT_ZERO in gen_unary.
Looks like trans_ctzw is missing
ctx->ol = MXL_RV32;
similar to trans_ctpopw just below.
r~
prev parent reply other threads:[~2023-02-03 16:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 14:00 [PATCH] target/riscv: fix ctzw behavior Vladimir Isaev
2023-02-03 16:56 ` Richard Henderson [this message]
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=0078f162-02ca-628e-7695-27944b491144@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=vladimir.isaev@syntacore.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).