|
From: Andreas A. <ar...@so...> - 2026-03-18 18:39:38
|
https://sourceware.org/cgit/valgrind/commit/?id=dcf06a3908e20cab2691aa363689ed6effcc2f6a commit dcf06a3908e20cab2691aa363689ed6effcc2f6a Author: Andreas Arnez <ar...@li...> Date: Wed Mar 18 18:27:44 2026 +0100 s390x: Fix negative signed immediate operands in code gen The helper functions that check whether an integer constant fits into a 16-bit or 32-bit signed immediate operand always return false for negative values. This prevents the use of negative immediate operands altogether and may lead to unnecessarily clumsy code being emitted, such as v-add %r8,-160 8 bytes iihf %r0,4294967295 iilf %r0,4294967136 agr %r8,%r0 instead of v-add %r8,-160 8 bytes aghi %r8,-160 This behavior is a regression; it was introduced by commit #0282c1cfc9015b69d09 -- s390: Tweak a few helper functions. However, the previous code was perhaps a bit obscure. So instead of reverting to that, use simple checks like "val + 0x8000 <= 0xFFFF", exploiting standard C integer semantics. Diff: --- VEX/priv/host_s390_defs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index 28b66ef5c7..8ff386cc4a 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -4176,21 +4176,21 @@ s390_emit_RISBG(UChar *p, UChar r1, UChar r2, UChar i3, Char i4, UChar i5) static __inline__ Bool uint_fits_signed_16bit(UInt val) { - return val <= 0x7FFFu; + return val + 0x8000 <= 0xFFFF; } static __inline__ Bool ulong_fits_signed_16bit(ULong val) { - return val <= 0x7FFFu; + return val + 0x8000 <= 0xFFFF; } static __inline__ Bool ulong_fits_signed_32bit(ULong val) { - return val <= 0x7FFFFFFFu; + return val + 0x80000000 <= 0xFFFFFFFF; } |