qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: c@jia.je, philmd@redhat.com, git@xen0n.name, maobibo@loongson.cn
Subject: Re: [PATCH] tcg: Fixes set const_args[i] wrong value when instructions imm is 0
Date: Thu, 1 Feb 2024 07:16:12 +1000	[thread overview]
Message-ID: <70186760-61be-4b44-8c0f-eb6acb4587f2@linaro.org> (raw)
In-Reply-To: <20240131072740.2569850-1-gaosong@loongson.cn>

On 1/31/24 17:27, Song Gao wrote:
> It seems that tcg_reg_alloc_op() set const_args[i] wrong value
> when instructions imm is 0. The LoongArch tcg_out_vec_op() cmp_vec
> use the wrong const_args[2].
> e.g
>     The wrong const_args[2] is 0.
>     IN: vslti.w v5, v4, 0x0   OUT: vslt.w  v1, v1, v0
> 
>     The right const_args[2] is 1.
>     IN: vslti.w v5, v4, 0x0   OUT: vslti.w v1, v1, 0x0
> 
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2136
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
>   tcg/tcg.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index e2c38f6d11..5b290123bc 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -4808,7 +4808,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
>           arg_ct = &def->args_ct[i];
>           ts = arg_temp(arg);
>   
> -        if (ts->val_type == TEMP_VAL_CONST
> +        if ((ts->val_type == TEMP_VAL_CONST || ts->kind == TEMP_CONST)
>               && tcg_target_const_match(ts->val, ts->type, arg_ct->ct, TCGOP_VECE(op))) {
>               /* constant is OK for instruction */
>               const_args[i] = 1;

This is wrong.

I strongly suspect that the TEMP_CONST value 0 has been loaded into a register for use in 
another operation, and the register allocator sees that it is still there.


r~


  reply	other threads:[~2024-01-31 21:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31  7:27 [PATCH] tcg: Fixes set const_args[i] wrong value when instructions imm is 0 Song Gao
2024-01-31 21:16 ` Richard Henderson [this message]
2024-02-01  1:17   ` gaosong

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=70186760-61be-4b44-8c0f-eb6acb4587f2@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=c@jia.je \
    --cc=gaosong@loongson.cn \
    --cc=git@xen0n.name \
    --cc=maobibo@loongson.cn \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.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 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).