qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-arm: Fix GE bits for v6media signed modulo arithmetic
@ 2011-03-10 18:51 Peter Maydell
  2011-03-22  6:54 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2011-03-10 18:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Fix the signed modulo arithmetic helpers for the v6media
instructions (SADD8, SSUB8, SADD16, SSUB16, SASX, SSAX) to set
the GE bits correctly (based on the result of the add or subtract
before it is truncated to 16 bits, not after).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/helper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index d360121..4f2b440 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2171,7 +2171,7 @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
 /* Signed modulo arithmetic.  */
 #define SARITH16(a, b, n, op) do { \
     int32_t sum; \
-    sum = (int16_t)((uint16_t)(a) op (uint16_t)(b)); \
+    sum = (int32_t)(int16_t)(a) op (int32_t)(int16_t)(b); \
     RESULT(sum, n, 16); \
     if (sum >= 0) \
         ge |= 3 << (n * 2); \
@@ -2179,7 +2179,7 @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
 
 #define SARITH8(a, b, n, op) do { \
     int32_t sum; \
-    sum = (int8_t)((uint8_t)(a) op (uint8_t)(b)); \
+    sum = (int32_t)(int8_t)(a) op (int32_t)(int8_t)(b); \
     RESULT(sum, n, 8); \
     if (sum >= 0) \
         ge |= 1 << n; \
-- 
1.7.1

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

* Re: [Qemu-devel] [PATCH] target-arm: Fix GE bits for v6media signed modulo arithmetic
  2011-03-10 18:51 [Qemu-devel] [PATCH] target-arm: Fix GE bits for v6media signed modulo arithmetic Peter Maydell
@ 2011-03-22  6:54 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2011-03-22  6:54 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches

On Thu, Mar 10, 2011 at 06:51:49PM +0000, Peter Maydell wrote:
> Fix the signed modulo arithmetic helpers for the v6media
> instructions (SADD8, SSUB8, SADD16, SSUB16, SASX, SSAX) to set
> the GE bits correctly (based on the result of the add or subtract
> before it is truncated to 16 bits, not after).
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  target-arm/helper.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Thanks, applied.

> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index d360121..4f2b440 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -2171,7 +2171,7 @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
>  /* Signed modulo arithmetic.  */
>  #define SARITH16(a, b, n, op) do { \
>      int32_t sum; \
> -    sum = (int16_t)((uint16_t)(a) op (uint16_t)(b)); \
> +    sum = (int32_t)(int16_t)(a) op (int32_t)(int16_t)(b); \
>      RESULT(sum, n, 16); \
>      if (sum >= 0) \
>          ge |= 3 << (n * 2); \
> @@ -2179,7 +2179,7 @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
>  
>  #define SARITH8(a, b, n, op) do { \
>      int32_t sum; \
> -    sum = (int8_t)((uint8_t)(a) op (uint8_t)(b)); \
> +    sum = (int32_t)(int8_t)(a) op (int32_t)(int8_t)(b); \
>      RESULT(sum, n, 8); \
>      if (sum >= 0) \
>          ge |= 1 << n; \
> -- 
> 1.7.1
> 
> 
> 

-- 
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:[~2011-03-22  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-10 18:51 [Qemu-devel] [PATCH] target-arm: Fix GE bits for v6media signed modulo arithmetic Peter Maydell
2011-03-22  6:54 ` 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).