qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted
@ 2023-11-20  6:59 Song Gao
  2023-11-20 12:13 ` [PATCH-for-8.2 " Philippe Mathieu-Daudé
  2023-11-20 15:59 ` [PATCH " Richard Henderson
  0 siblings, 2 replies; 4+ messages in thread
From: Song Gao @ 2023-11-20  6:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, philmd, git, c, maobibo

On LoongArch host,  we got an Aborted from tcg_out_mov().

qemu-x86_64 configure with '--enable-debug'.

> (gdb) b /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
> Breakpoint 1 at 0x2576f0: file /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc, line 312.
> (gdb) run hello
[...]
> Thread 1 "qemu-x86_64" hit Breakpoint 1, tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2,
>     arg=TCG_REG_V0) at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
> 312           g_assert_not_reached();
> (gdb) bt
> #0  tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2, arg=TCG_REG_V0)
>     at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
> #1  0x000000aaaad0fee0 in tcg_reg_alloc_mov (s=0xaaaae91760 <tcg_init_ctx>, op=0xaaaaf67c20) at ../tcg/tcg.c:4632
> #2  0x000000aaaad142f4 in tcg_gen_code (s=0xaaaae91760 <tcg_init_ctx>, tb=0xffe8030340 <code_gen_buffer+197328>,
>     pc_start=4346094) at ../tcg/tcg.c:6135
[...]
> (gdb) c
> Continuing.
> **
> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
> Bail out! ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
>
> Thread 1 "qemu-x86_64" received signal SIGABRT, Aborted.
> 0x000000fff7b1c390 in raise () from /lib64/libc.so.6
> (gdb) q

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 tcg/loongarch64/tcg-target.c.inc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index a588fb3085..5f68040230 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -308,6 +308,9 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
          */
         tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
         break;
+    case TCG_TYPE_V128:
+        tcg_out_opc_vaddi_du(s, ret, arg, 0);
+        break;
     default:
         g_assert_not_reached();
     }
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH-for-8.2 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted
  2023-11-20  6:59 [PATCH 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted Song Gao
@ 2023-11-20 12:13 ` Philippe Mathieu-Daudé
  2023-11-20 15:59 ` [PATCH " Richard Henderson
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-20 12:13 UTC (permalink / raw)
  To: Song Gao, qemu-devel; +Cc: richard.henderson, git, c, maobibo

On 20/11/23 07:59, Song Gao wrote:
> On LoongArch host,  we got an Aborted from tcg_out_mov().
> 
> qemu-x86_64 configure with '--enable-debug'.
> 
>> (gdb) b /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>> Breakpoint 1 at 0x2576f0: file /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc, line 312.
>> (gdb) run hello
> [...]
>> Thread 1 "qemu-x86_64" hit Breakpoint 1, tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2,
>>      arg=TCG_REG_V0) at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>> 312           g_assert_not_reached();
>> (gdb) bt
>> #0  tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2, arg=TCG_REG_V0)
>>      at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>> #1  0x000000aaaad0fee0 in tcg_reg_alloc_mov (s=0xaaaae91760 <tcg_init_ctx>, op=0xaaaaf67c20) at ../tcg/tcg.c:4632
>> #2  0x000000aaaad142f4 in tcg_gen_code (s=0xaaaae91760 <tcg_init_ctx>, tb=0xffe8030340 <code_gen_buffer+197328>,
>>      pc_start=4346094) at ../tcg/tcg.c:6135
> [...]
>> (gdb) c
>> Continuing.
>> **
>> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
>> Bail out! ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
>>
>> Thread 1 "qemu-x86_64" received signal SIGABRT, Aborted.
>> 0x000000fff7b1c390 in raise () from /lib64/libc.so.6
>> (gdb) q

Available since commit af88a28414 ("tcg/loongarch64: Import LSX
instructions"), missed when LSX host instruction got enabled in
commit 16288ded94 ("tcg/loongarch64: Lower basic tcg vec ops to LSX").


Fixes: 16288ded94 ("tcg/loongarch64: Lower basic tcg vec ops to LSX")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
>   tcg/loongarch64/tcg-target.c.inc | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
> index a588fb3085..5f68040230 100644
> --- a/tcg/loongarch64/tcg-target.c.inc
> +++ b/tcg/loongarch64/tcg-target.c.inc
> @@ -308,6 +308,9 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
>            */
>           tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
>           break;
> +    case TCG_TYPE_V128:
> +        tcg_out_opc_vaddi_du(s, ret, arg, 0);
> +        break;
>       default:
>           g_assert_not_reached();
>       }



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted
  2023-11-20  6:59 [PATCH 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted Song Gao
  2023-11-20 12:13 ` [PATCH-for-8.2 " Philippe Mathieu-Daudé
@ 2023-11-20 15:59 ` Richard Henderson
  2023-11-21  1:50   ` gaosong
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2023-11-20 15:59 UTC (permalink / raw)
  To: Song Gao, qemu-devel; +Cc: philmd, git, c, maobibo

On 11/19/23 22:59, Song Gao wrote:
> On LoongArch host,  we got an Aborted from tcg_out_mov().
> 
> qemu-x86_64 configure with '--enable-debug'.
> 
>> (gdb) b /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>> Breakpoint 1 at 0x2576f0: file /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc, line 312.
>> (gdb) run hello
> [...]
>> Thread 1 "qemu-x86_64" hit Breakpoint 1, tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2,
>>      arg=TCG_REG_V0) at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>> 312           g_assert_not_reached();
>> (gdb) bt
>> #0  tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2, arg=TCG_REG_V0)
>>      at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>> #1  0x000000aaaad0fee0 in tcg_reg_alloc_mov (s=0xaaaae91760 <tcg_init_ctx>, op=0xaaaaf67c20) at ../tcg/tcg.c:4632
>> #2  0x000000aaaad142f4 in tcg_gen_code (s=0xaaaae91760 <tcg_init_ctx>, tb=0xffe8030340 <code_gen_buffer+197328>,
>>      pc_start=4346094) at ../tcg/tcg.c:6135
> [...]
>> (gdb) c
>> Continuing.
>> **
>> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
>> Bail out! ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
>>
>> Thread 1 "qemu-x86_64" received signal SIGABRT, Aborted.
>> 0x000000fff7b1c390 in raise () from /lib64/libc.so.6
>> (gdb) q
> 
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
>   tcg/loongarch64/tcg-target.c.inc | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
> index a588fb3085..5f68040230 100644
> --- a/tcg/loongarch64/tcg-target.c.inc
> +++ b/tcg/loongarch64/tcg-target.c.inc
> @@ -308,6 +308,9 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
>            */
>           tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
>           break;
> +    case TCG_TYPE_V128:
> +        tcg_out_opc_vaddi_du(s, ret, arg, 0);
> +        break;

Is add with immediate zero really the canonical alias for "vector move"?

There is often some form that is recommended by the architecture, so that it may be 
recognized for register renaming.  Usually it is some form of logic instruction, not 
arithmetic.  I see that LLVM emits "vori.b dst, src, 0" for this case.

Regardless, this patch works to fix the assert so,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted
  2023-11-20 15:59 ` [PATCH " Richard Henderson
@ 2023-11-21  1:50   ` gaosong
  0 siblings, 0 replies; 4+ messages in thread
From: gaosong @ 2023-11-21  1:50 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: philmd, git, c, maobibo

在 2023/11/20 下午11:59, Richard Henderson 写道:
> On 11/19/23 22:59, Song Gao wrote:
>> On LoongArch host,  we got an Aborted from tcg_out_mov().
>>
>> qemu-x86_64 configure with '--enable-debug'.
>>
>>> (gdb) b /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>>> Breakpoint 1 at 0x2576f0: file 
>>> /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc, line 312.
>>> (gdb) run hello
>> [...]
>>> Thread 1 "qemu-x86_64" hit Breakpoint 1, tcg_out_mov (s=0xaaaae91760 
>>> <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2,
>>>      arg=TCG_REG_V0) at 
>>> /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>>> 312           g_assert_not_reached();
>>> (gdb) bt
>>> #0  tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, 
>>> ret=TCG_REG_V2, arg=TCG_REG_V0)
>>>      at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
>>> #1  0x000000aaaad0fee0 in tcg_reg_alloc_mov (s=0xaaaae91760 
>>> <tcg_init_ctx>, op=0xaaaaf67c20) at ../tcg/tcg.c:4632
>>> #2  0x000000aaaad142f4 in tcg_gen_code (s=0xaaaae91760 
>>> <tcg_init_ctx>, tb=0xffe8030340 <code_gen_buffer+197328>,
>>>      pc_start=4346094) at ../tcg/tcg.c:6135
>> [...]
>>> (gdb) c
>>> Continuing.
>>> **
>>> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: 
>>> code should not be reached
>>> Bail out! 
>>> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: 
>>> code should not be reached
>>>
>>> Thread 1 "qemu-x86_64" received signal SIGABRT, Aborted.
>>> 0x000000fff7b1c390 in raise () from /lib64/libc.so.6
>>> (gdb) q
>>
>> Signed-off-by: Song Gao <gaosong@loongson.cn>
>> ---
>>   tcg/loongarch64/tcg-target.c.inc | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/tcg/loongarch64/tcg-target.c.inc 
>> b/tcg/loongarch64/tcg-target.c.inc
>> index a588fb3085..5f68040230 100644
>> --- a/tcg/loongarch64/tcg-target.c.inc
>> +++ b/tcg/loongarch64/tcg-target.c.inc
>> @@ -308,6 +308,9 @@ static bool tcg_out_mov(TCGContext *s, TCGType 
>> type, TCGReg ret, TCGReg arg)
>>            */
>>           tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
>>           break;
>> +    case TCG_TYPE_V128:
>> +        tcg_out_opc_vaddi_du(s, ret, arg, 0);
>> +        break;
>
> Is add with immediate zero really the canonical alias for "vector move"?
>
> There is often some form that is recommended by the architecture, so 
> that it may be recognized for register renaming.  Usually it is some 
> form of logic instruction, not arithmetic.  I see that LLVM emits 
> "vori.b dst, src, 0" for this case.
> adfadf
you are right,
I see  the insn  'mov '  opcode is '00150000'.  it is 'or dst, src, zero'.

Thanks.
Song Gao
> Regardless, this patch works to fix the assert so,
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
>
> r~



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-21  1:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-20  6:59 [PATCH 1/1] tcg/loongarch64: Fix tcg_out_mov() Aborted Song Gao
2023-11-20 12:13 ` [PATCH-for-8.2 " Philippe Mathieu-Daudé
2023-11-20 15:59 ` [PATCH " Richard Henderson
2023-11-21  1:50   ` gaosong

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).