diff mbox

[1/3] target-s390x: fix CC computation for LOAD POSITIVE instructions

Message ID 1431956400-19091-1-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno May 18, 2015, 1:39 p.m. UTC
LOAD POSITIVE instructions (LPR, LPGR and LPGFR) set the following
condition code:
  0: Result zero; no overflow
  1: --
  2: Result greater than zero; no overflow
  3: Overflow

The current code wrongly returns 1 instead of 2 in case of a result
greater than 0. This patches fixes that. This fixes the marshalling of
the value '0L' in Python.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-s390x/cc_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Henderson May 18, 2015, 3:42 p.m. UTC | #1
On 05/18/2015 06:39 AM, Aurelien Jarno wrote:
> LOAD POSITIVE instructions (LPR, LPGR and LPGFR) set the following
> condition code:
>   0: Result zero; no overflow
>   1: --
>   2: Result greater than zero; no overflow
>   3: Overflow
> 
> The current code wrongly returns 1 instead of 2 in case of a result
> greater than 0. This patches fixes that. This fixes the marshalling of
> the value '0L' in Python.
> 
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Alexander Graf <agraf@suse.de>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  target-s390x/cc_helper.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
Alexander Graf May 18, 2015, 5:04 p.m. UTC | #2
On 05/18/2015 03:39 PM, Aurelien Jarno wrote:
> LOAD POSITIVE instructions (LPR, LPGR and LPGFR) set the following
> condition code:
>    0: Result zero; no overflow
>    1: --
>    2: Result greater than zero; no overflow
>    3: Overflow
>
> The current code wrongly returns 1 instead of 2 in case of a result
> greater than 0. This patches fixes that. This fixes the marshalling of
> the value '0L' in Python.
>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Alexander Graf <agraf@suse.de>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

Thanks, applied all to s390-next.


Alex
diff mbox

Patch

diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
index 00bc883..bfce3f1 100644
--- a/target-s390x/cc_helper.c
+++ b/target-s390x/cc_helper.c
@@ -195,7 +195,7 @@  static uint32_t cc_calc_abs_64(int64_t dst)
     if ((uint64_t)dst == 0x8000000000000000ULL) {
         return 3;
     } else if (dst) {
-        return 1;
+        return 2;
     } else {
         return 0;
     }
@@ -296,7 +296,7 @@  static uint32_t cc_calc_abs_32(int32_t dst)
     if ((uint32_t)dst == 0x80000000UL) {
         return 3;
     } else if (dst) {
-        return 1;
+        return 2;
     } else {
         return 0;
     }