5330dfb
commit 9545e9f96beda6e9f2205bdb3c3e96edaf8d9e2b
5330dfb
Author: Andreas Arnez <arnez@linux.ibm.com>
5330dfb
Date:   Tue Oct 30 17:06:38 2018 +0100
5330dfb
5330dfb
    Bug 400491 s390x: Sign-extend immediate operand of LOCHI and friends
5330dfb
    
5330dfb
    The VEX implementation of each of the z/Architecture instructions LOCHI,
5330dfb
    LOCHHI, and LOCGHI treats the immediate 16-bit operand as an unsigned
5330dfb
    integer instead of a signed integer.  This is fixed.
5330dfb
5330dfb
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
5330dfb
index 60b6081..9c4d79b 100644
5330dfb
--- a/VEX/priv/guest_s390_toIR.c
5330dfb
+++ b/VEX/priv/guest_s390_toIR.c
5330dfb
@@ -16307,7 +16307,7 @@ static const HChar *
5330dfb
 s390_irgen_LOCHHI(UChar r1, UChar m3, UShort i2, UChar unused)
5330dfb
 {
5330dfb
    next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0)));
5330dfb
-   put_gpr_w0(r1, mkU32(i2));
5330dfb
+   put_gpr_w0(r1, mkU32((UInt)(Int)(Short)i2));
5330dfb
 
5330dfb
    return "lochhi";
5330dfb
 }
5330dfb
@@ -16316,7 +16316,7 @@ static const HChar *
5330dfb
 s390_irgen_LOCHI(UChar r1, UChar m3, UShort i2, UChar unused)
5330dfb
 {
5330dfb
    next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0)));
5330dfb
-   put_gpr_w1(r1, mkU32(i2));
5330dfb
+   put_gpr_w1(r1, mkU32((UInt)(Int)(Short)i2));
5330dfb
 
5330dfb
    return "lochi";
5330dfb
 }
5330dfb
@@ -16325,7 +16325,7 @@ static const HChar *
5330dfb
 s390_irgen_LOCGHI(UChar r1, UChar m3, UShort i2, UChar unused)
5330dfb
 {
5330dfb
    next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0)));
5330dfb
-   put_gpr_dw0(r1, mkU64(i2));
5330dfb
+   put_gpr_dw0(r1, mkU64((UInt)(Int)(Short)i2));
5330dfb
 
5330dfb
    return "locghi";
5330dfb
 }