qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix bug in translation of REVSH
@ 2010-10-18 12:49 Johan Bengtsson
  2010-12-27 18:57 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Bengtsson @ 2010-10-18 12:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Johan Bengtsson

The translation of REVSH shifted the low byte 8 steps left before performing
an 8-bit sign extend, causing this part of the expression to alwas be 0.
The fix for this is either to extend before shifting or switch to a 16-bit
extend. I choose the former.

Signed-off-by: Johan Bengtsson <teofrastius@gmail.com>
---
 target-arm/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 652cac9..e2fa4df 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -253,8 +253,8 @@ static void gen_revsh(TCGv var)
     TCGv tmp = new_tmp();
     tcg_gen_shri_i32(tmp, var, 8);
     tcg_gen_andi_i32(tmp, tmp, 0x00ff);
-    tcg_gen_shli_i32(var, var, 8);
     tcg_gen_ext8s_i32(var, var);
+    tcg_gen_shli_i32(var, var, 8);
     tcg_gen_or_i32(var, var, tmp);
     dead_tmp(tmp);
 }
-- 
1.7.0.4

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

* Re: [Qemu-devel] [PATCH] Fix bug in translation of REVSH
  2010-10-18 12:49 [Qemu-devel] [PATCH] Fix bug in translation of REVSH Johan Bengtsson
@ 2010-12-27 18:57 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2010-12-27 18:57 UTC (permalink / raw)
  To: Johan Bengtsson; +Cc: qemu-devel

On Mon, Oct 18, 2010 at 02:49:36PM +0200, Johan Bengtsson wrote:
> The translation of REVSH shifted the low byte 8 steps left before performing
> an 8-bit sign extend, causing this part of the expression to alwas be 0.
> The fix for this is either to extend before shifting or switch to a 16-bit
> extend. I choose the former.
> 
> Signed-off-by: Johan Bengtsson <teofrastius@gmail.com>
> ---
>  target-arm/translate.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks for this patch. While it is correct, I have committed a different
fix using tcg_gen_bswap16, so that the generated code can be optimized
on some hosts.

> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index 652cac9..e2fa4df 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -253,8 +253,8 @@ static void gen_revsh(TCGv var)
>      TCGv tmp = new_tmp();
>      tcg_gen_shri_i32(tmp, var, 8);
>      tcg_gen_andi_i32(tmp, tmp, 0x00ff);
> -    tcg_gen_shli_i32(var, var, 8);
>      tcg_gen_ext8s_i32(var, var);
> +    tcg_gen_shli_i32(var, var, 8);
>      tcg_gen_or_i32(var, var, tmp);
>      dead_tmp(tmp);
>  }
> -- 
> 1.7.0.4
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

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

end of thread, other threads:[~2010-12-27 21:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 12:49 [Qemu-devel] [PATCH] Fix bug in translation of REVSH Johan Bengtsson
2010-12-27 18:57 ` Aurelien Jarno

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