From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: WANG Rui <wangrui@loongson.cn>,
Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, qemu@hev.cc
Subject: Re: [PATCH] tcg/optimize: Fix folding of vector bitsel
Date: Wed, 24 Sep 2025 06:03:06 +0200 [thread overview]
Message-ID: <c0fc38df-9c52-406f-8d8b-f2496b4e410f@linaro.org> (raw)
In-Reply-To: <20250919124901.2756538-1-wangrui@loongson.cn>
On 19/9/25 14:49, WANG Rui wrote:
> It looks like a typo.
Likely from the TCG_TARGET_HAS_andc_vec case.
> When the false value (C) is the constant -1, the
> correct fold should be: R = B | ~A
>
> Reproducer (LoongArch64 assembly):
>
> .text
> .globl _start
> _start:
> vldi $vr1, 3073
> vldi $vr2, 1023
> vbitsel.v $vr0, $vr2, $vr1, $vr2
> vpickve2gr.d $a1, $vr0, 1
> xori $a0, $a1, 1
> li.w $a7, 93
> syscall 0
>
> Fixes: e58b977238e3 ("tcg/optimize: Optimize bitsel_vec")
> Link: https://github.com/llvm/llvm-project/issues/159610
> Signed-off-by: WANG Rui <wangrui@loongson.cn>
> ---
> tcg/optimize.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index 3638ab9fea..f69702b26e 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -1568,9 +1568,10 @@ static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)
> return fold_and(ctx, op);
> }
> if (fv == -1 && TCG_TARGET_HAS_orc_vec) {
> + TCGArg ta = op->args[2];
> op->opc = INDEX_op_orc_vec;
> op->args[2] = op->args[1];
> - op->args[1] = op->args[3];
> + op->args[1] = ta;
> return fold_orc(ctx, op);
> }
> }
Looks correct, but I don't understand the swap. Can't we justkeep the
same argument order for an ORC opcode? I'd have done:
-- >8 --
@@ -1569,8 +1569,6 @@ static bool fold_bitsel_vec(OptContext *ctx, TCGOp
*op)
}
if (fv == -1 && TCG_TARGET_HAS_orc_vec) {
op->opc = INDEX_op_orc_vec;
- op->args[2] = op->args[1];
- op->args[1] = op->args[3];
return fold_orc(ctx, op);
}
}
---
next prev parent reply other threads:[~2025-09-24 4:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 12:49 [PATCH] tcg/optimize: Fix folding of vector bitsel WANG Rui
2025-09-23 23:17 ` Richard Henderson
2025-09-24 4:03 ` Philippe Mathieu-Daudé [this message]
2025-09-24 4:29 ` WANG Rui
2025-09-25 0:23 ` Philippe Mathieu-Daudé
2025-09-24 19:31 ` Michael Tokarev
2025-09-24 19:33 ` 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=c0fc38df-9c52-406f-8d8b-f2496b4e410f@linaro.org \
--to=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu@hev.cc \
--cc=richard.henderson@linaro.org \
--cc=wangrui@loongson.cn \
/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).