https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92925
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|RTl expansion throws away |RTL expansion throws away
|alignment info |misalignment info
--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
So there is indeed a disconnect between set_mem_attributes_minus_bitpos and
adjust_address when it comes to (mis)alignment: the former wants to compute the
alignment of the final reference, corresponding to T, and put it on the MEM but
adjust_address will again adjust the alignment based on the pending BITPOS, so
this cannot work if there is a misalignment info to be preserved.
There is already the same issue for the offset recorded in MEM_ATTRS: if we
reset the MEM_EXPR and the MEM_OFFSET in set_mem_attributes_minus_bitpos from
T, then we set apply_bitpos to subtract it preventively at the end:
/* If we modified OFFSET based on T, then subtract the outstanding
bit position offset. Similarly, increase the size of the accessed
object to contain the negative offset. */
if (maybe_ne (apply_bitpos, 0))
{
gcc_assert (attrs.offset_known_p);
poly_int64 bytepos = bits_to_bytes_round_down (apply_bitpos);
attrs.offset -= bytepos;
if (attrs.size_known_p)
attrs.size += bytepos;
}
so that adjust_address can add it back and get the correct result. But that's
more problematic for the alignment.