[Bug tree-optimization/79737] [7 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes)
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 28 08:41:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79737
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is in:
unsigned int padding
= byte_size - ROUND_UP (bitlen, BITS_PER_UNIT) / BITS_PER_UNIT - 1;
if (padding != 0
|| bitlen % BITS_PER_UNIT != 0)
{
/* On big-endian the padding is at the 'front' so just skip the initial
bytes. */
if (BYTES_BIG_ENDIAN)
tmpbuf += padding;
byte_size -= padding;
if (bitlen % BITS_PER_UNIT != 0)
{
if (BYTES_BIG_ENDIAN)
clear_bit_region_be (tmpbuf, BITS_PER_UNIT - 1,
BITS_PER_UNIT - (bitlen % BITS_PER_UNIT));
else
clear_bit_region (tmpbuf, bitlen,
byte_size * BITS_PER_UNIT - bitlen);
}
}
We have initially byte_size of 5 (size of int + 1), bitpos 19 and bitlen 24.
That means we have padding 1, but bitlen % BITS_PER_UNIT == 0.
We need to clear tmpbuf[byte_size - 1] even when bitlen is multiple of
BITS_PER_UNIT, at least if !BYTES_BIG_ENDIAN. Now to figure out if it needs to
be done in big endian too.
More information about the Gcc-bugs
mailing list