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.
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;
}