qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcg/aarch64: fix assertion failure on TSTxx of UINT32_MAX
@ 2024-03-11  8:26 Paolo Bonzini
  2024-03-11 12:06 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2024-03-11  8:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson

These are translated to CBZ and CBNZ instructions, and the code generation part
of tcg_out_brcond checks that c is one of TCG_COND_EQ or TCG_COND_NE.

Fixes: 34aff3c2e06 ("tcg/aarch64: Generate CBNZ for TSTNE of UINT32_MAX", 2024-02-03)
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tcg/aarch64/tcg-target.c.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
index dec8ecc1b65..6ed174bd172 100644
--- a/tcg/aarch64/tcg-target.c.inc
+++ b/tcg/aarch64/tcg-target.c.inc
@@ -1465,6 +1465,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a,
     case TCG_COND_TSTNE:
         /* tst xN,0xffffffff; b.ne L -> cbnz wN,L */
         if (b_const && b == UINT32_MAX) {
+            c = (c == TCG_COND_TSTEQ ? TCG_COND_EQ : TCG_COND_NE);
             ext = TCG_TYPE_I32;
             need_cmp = false;
             break;
-- 
2.43.2



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

* Re: [PATCH] tcg/aarch64: fix assertion failure on TSTxx of UINT32_MAX
  2024-03-11  8:26 [PATCH] tcg/aarch64: fix assertion failure on TSTxx of UINT32_MAX Paolo Bonzini
@ 2024-03-11 12:06 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-03-11 12:06 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Richard Henderson

On 11/3/24 09:26, Paolo Bonzini wrote:
> These are translated to CBZ and CBNZ instructions, and the code generation part
> of tcg_out_brcond checks that c is one of TCG_COND_EQ or TCG_COND_NE.
> 
> Fixes: 34aff3c2e06 ("tcg/aarch64: Generate CBNZ for TSTNE of UINT32_MAX", 2024-02-03)
> Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   tcg/aarch64/tcg-target.c.inc | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
> index dec8ecc1b65..6ed174bd172 100644
> --- a/tcg/aarch64/tcg-target.c.inc
> +++ b/tcg/aarch64/tcg-target.c.inc
> @@ -1465,6 +1465,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a,
>       case TCG_COND_TSTNE:
>           /* tst xN,0xffffffff; b.ne L -> cbnz wN,L */
>           if (b_const && b == UINT32_MAX) {
> +            c = (c == TCG_COND_TSTEQ ? TCG_COND_EQ : TCG_COND_NE);

Correct. Richard posted the same fix but using tcg_tst_eqne_cond:
https://lore.kernel.org/qemu-devel/20240309175102.726332-3-richard.henderson@linaro.org/

>               ext = TCG_TYPE_I32;
>               need_cmp = false;
>               break;



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

end of thread, other threads:[~2024-03-11 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-11  8:26 [PATCH] tcg/aarch64: fix assertion failure on TSTxx of UINT32_MAX Paolo Bonzini
2024-03-11 12:06 ` Philippe Mathieu-Daudé

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