This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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)


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]