https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78355

--- Comment #4 from pipcet at gmail dot com ---
(In reply to Richard Biener from comment #2)
>         if (!SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (reg))
>             || (MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (innermode)
>                   && SLOW_UNALIGNED_ACCESS (innermode, MEM_ALIGN (reg)))
>             || MEM_ALIGN (reg) >= GET_MODE_ALIGNMENT (mode))
>           return true;
> 
> looks good to me given
> 
> gcc/defaults.h:#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT
> 
> doesn't do that check itself (maybe it and all ports should be fixed
> instead...)

Maybe it would make sense to introduce an intermediate function which does both
checks? That would make the code easier to read, and save us having to change
many targets.

bool fast_access(machine_mode mode, int align)
{
  return (align >= GET_MODE_ALIGNMENT (mode)
          || !SLOW_UNALIGNED_ACCESS (mode, align));
}

(BTW, how do we deal with the case when we're accessing the last 16-bit word on
a page, and the next 16 bits are no longer mapped?  There's a comment that
suggests no 32-bit access would be generated in this case, but I tried it and
it appears to happen).

Reply via email to