From: Richard Henderson <richard.henderson@linaro.org>
To: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>, qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com,
alistair.francis@wdc.com, dbarboza@ventanamicro.com,
liwei1518@gmail.com, bmeng.cn@gmail.com,
TANG Tiancheng <tangtiancheng.ttc@alibaba-inc.com>
Subject: Re: [PATCH v2 08/14] tcg/riscv: Implement vector cmp ops
Date: Tue, 3 Sep 2024 07:51:31 -0700 [thread overview]
Message-ID: <181d95aa-9a2c-465b-b549-076572db601a@linaro.org> (raw)
In-Reply-To: <629e9969-157e-4f58-b48f-52aea4c0c48f@linaro.org>
On 9/2/24 23:45, Richard Henderson wrote:
> I think the first implementation should be simpler:
>
> CONST('C', TCG_CT_CONST_CMP_VI)
>
> tcg_target_const_match()
> {
> ...
> if ((ct & TCG_CT_CONST_CMP_VI) &&
> val >= tcg_cmpcond_to_rvv_vi[cond].min &&
> val <= tcg_cmpcond_to_rvv_vi[cond].max) {
> return true;
> }
> }
>
> case INDEX_op_cmp_vec:
> riscv_set_vec_config_vl_vece(s, type, vece);
> cond = args[3];
> if (c2) {
> tcg_out_opc_vi(s, tcg_cmpcond_to_rvv_vi[cond].op, a0, a1,
> a2 - tcg_cmpcond_to_rvv_vi[cond].adjust);
> } else if (tcg_cmpcond_to_rvv_vv[cond].swap) {
> tcg_out_opc_vv(s, tcg_cmpcond_to_rvv_vv[cond].op, a0, a2, a1);
> } else {
> tcg_out_opc_vv(s, tcg_cmpcond_to_rvv_vv[cond].op, a0, a1, a2);
> }
> break;
>
> This appears to not require any expansion in tcg_expand_vec_op at all.
I knew I should have slept on that answer.
Of course you need expansion, because riscv cmp_vv produces a mask.
However, I think we should simply model this as INDEX_op_cmpsel_vec:
case INDEX_op_cmpsel_vec:
riscv_set_vec_config_vl_vece(s, type, vece);
a3 = args[3];
a4 = args[4];
cond = args[5];
/* Use only vmerge_vim if possible, by inverting the test. */
if (const_args[4] && !const_args[3]) {
cond = tcg_cond_inv(cond);
a3 = a4;
a4 = args[3];
const_args[3] = true;
const_args[4] = false;
}
/* Perform the comparison into V0 mask. */
if (const_args[2]) {
tcg_out_opc_vi(s, tcg_cmpcond_to_rvv_vi[cond].op,
TCG_REG_V0, a1,
a2 - tcg_cmpcond_to_rvv_vi[cond].adjust);
} else if (tcg_cmpcond_to_rvv_vv[cond].swap) {
tcg_out_opc_vv(s, tcg_cmpcond_to_rvv_vv[cond].op,
TCG_REG_V0, a2, a1);
} else {
tcg_out_opc_vv(s, tcg_cmpcond_to_rvv_vv[cond].op,
TCG_REG_V0, a1, a2);
}
if (const_args[3]) {
if (const_args[4]) {
tcg_out_opc_vi(s, OPC_VMV_V_I, a0, TCG_REG_V0, a4, true);
a4 = a0;
}
tcg_out_opc_vim_mask(s, OPC_VMERGE_VIM, a0, a3, a4);
} else {
tcg_out_opc_vvm_mask(s, OPC_VMERGE_VVM, a0, a3, a4);
}
break;
Then INDEX_op_cmp_vec should be expanded to
INDEX_op_cmpsel_vec a0, a1, a2, -1, 0, a3
r~
next prev parent reply other threads:[~2024-09-03 14:52 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 6:15 [PATCH v2 00/14] tcg/riscv: Add support for vector LIU Zhiwei
2024-08-30 6:15 ` [PATCH v2 01/14] tcg/op-gvec: Fix iteration step in 32-bit operation LIU Zhiwei
2024-08-31 23:59 ` Richard Henderson
2024-08-30 6:15 ` [PATCH v2 02/14] util: Add RISC-V vector extension probe in cpuinfo LIU Zhiwei
2024-09-02 0:12 ` Richard Henderson
2024-08-30 6:15 ` [PATCH v2 03/14] tcg/riscv: Add basic support for vector LIU Zhiwei
2024-09-02 0:28 ` Richard Henderson
2024-08-30 6:15 ` [PATCH v2 04/14] tcg/riscv: Add riscv vset{i}vli support LIU Zhiwei
2024-09-02 1:06 ` Richard Henderson
2024-08-30 6:15 ` [PATCH v2 05/14] tcg/riscv: Implement vector load/store LIU Zhiwei
2024-09-02 1:31 ` Richard Henderson
2024-08-30 6:15 ` [PATCH v2 06/14] tcg/riscv: Implement vector mov/dup{m/i} LIU Zhiwei
2024-09-02 1:36 ` Richard Henderson
2024-08-30 6:16 ` [PATCH v2 07/14] tcg/riscv: Add support for basic vector opcodes LIU Zhiwei
2024-09-02 1:39 ` Richard Henderson
2024-08-30 6:16 ` [PATCH v2 08/14] tcg/riscv: Implement vector cmp ops LIU Zhiwei
2024-09-03 6:45 ` Richard Henderson
2024-09-03 14:51 ` Richard Henderson [this message]
2024-08-30 6:16 ` [PATCH v2 09/14] tcg/riscv: Implement vector neg ops LIU Zhiwei
2024-09-03 14:52 ` Richard Henderson
2024-08-30 6:16 ` [PATCH v2 10/14] tcg/riscv: Implement vector sat/mul ops LIU Zhiwei
2024-09-03 14:52 ` Richard Henderson
2024-08-30 6:16 ` [PATCH v2 11/14] tcg/riscv: Implement vector min/max ops LIU Zhiwei
2024-09-03 14:53 ` Richard Henderson
2024-08-30 6:16 ` [PATCH v2 12/14] tcg/riscv: Implement vector shs/v ops LIU Zhiwei
2024-09-03 14:54 ` Richard Henderson
2024-08-30 6:16 ` [PATCH v2 13/14] tcg/riscv: Implement vector roti/v/x shi ops LIU Zhiwei
2024-09-03 15:15 ` Richard Henderson
2024-09-04 15:25 ` LIU Zhiwei
2024-09-04 19:05 ` Richard Henderson
2024-09-05 1:40 ` LIU Zhiwei
2024-08-30 6:16 ` [PATCH v2 14/14] tcg/riscv: Enable native vector support for TCG host LIU Zhiwei
2024-09-03 15:02 ` Richard Henderson
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=181d95aa-9a2c-465b-b549-076572db601a@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=tangtiancheng.ttc@alibaba-inc.com \
--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).