qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Chao Liu <chao.liu@zevorn.cn>,
	paolo.savini@embecosm.com, npiggin@gmail.com,
	ebiggers@kernel.org, dbarboza@ventanamicro.com,
	palmer@dabbelt.com, alistair.francis@wdc.com,
	liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com
Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v8 1/2] target/riscv: Use tcg nodes for strided vector ld/st generation
Date: Mon, 15 Sep 2025 06:53:41 -0700	[thread overview]
Message-ID: <8e43c44f-609c-4a30-8559-a5dcb567b950@linaro.org> (raw)
In-Reply-To: <1f22506f44570abf3bb17bf144d398807be0ab40.1757690407.git.chao.liu@zevorn.cn>

On 9/13/25 02:17, Chao Liu wrote:
> +static void gen_check_vext_elem_mask(TCGLabel *label, TCGv_i64 mask, TCGv_i64 mask_offs)
> +{
> +    TCGv_i64 mask_offs_i64 = tcg_temp_new_i64();
> +    TCGv_ptr mask_offs_ptr = tcg_temp_new_ptr();
> +    TCGv_i64 mask_offs_rem = tcg_temp_new_i64();
> +    TCGv_i64 mask_elem = tcg_temp_new_i64();
> +
> +    tcg_gen_shri_tl(mask_offs_i64, mask_offs, 3);
> +    tcg_gen_add_tl(mask_offs_i64, mask_offs_i64, mask);
> +    tcg_gen_trunc_i64_ptr(mask_offs_ptr, mask_offs_i64);
> +    tcg_gen_ld_i64(mask_elem, mask_offs_ptr, 0);

You can remove the "mask" argument, simplifying the code here.

	tcg_gen_trunc_i64_ptr(ptr, mask_offs_i64);
	tcg_gen_add_ptr(ptr, ptr, tcg_env);
	tcg_gen_ld_i64(mask_elem, ptr, vreg_ofs(s, 0))

You can also change mask_offs to TCGv_i32, which replaces

	tcg_gen_extu_i32_ptr(pr, mask_offs_i32);

which more obviously does not discard data from mask_offs.


> +    tcg_gen_andi_tl(mask_offs_rem, mask_offs, 7);
> +    tcg_gen_shr_tl(mask_elem, mask_elem, mask_offs_rem);

The mask of 7 suggests you're only interested in the low 8 bits.  Which means either the 
load is wrong (we don't need to be loading 64 bits), or the mask and shift are wrong.


> +    tcg_gen_andi_tl(mask_elem, mask_elem, 1);
> +    tcg_gen_brcond_i64(TCG_COND_TSTNE, mask_elem, tcg_constant_i64(1), label);

The andi before the brcond is redundant with the TSTNE.


r~


  reply	other threads:[~2025-09-15 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-13  9:17 [PATCH v8 0/2] Generate strided vector loads/stores with tcg nodes Chao Liu
2025-09-13  9:17 ` [PATCH v8 1/2] target/riscv: Use tcg nodes for strided vector ld/st generation Chao Liu
2025-09-15 13:53   ` Richard Henderson [this message]
2025-09-16  5:48     ` Chao Liu
2025-09-13  9:17 ` [PATCH v8 2/2] tests/tcg/riscv64: Add test for vlsseg8e32 instruction Chao Liu

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=8e43c44f-609c-4a30-8559-a5dcb567b950@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=chao.liu@zevorn.cn \
    --cc=dbarboza@ventanamicro.com \
    --cc=ebiggers@kernel.org \
    --cc=liwei1518@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=paolo.savini@embecosm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.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).