This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/58041] Unaligned access to arrays in packed structure
- From: "wschmidt at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 01 Aug 2013 18:29:36 +0000
- Subject: [Bug middle-end/58041] Unaligned access to arrays in packed structure
- Auto-submitted: auto-generated
- References: <bug-58041-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58041
--- Comment #14 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
(In reply to Bernd Edlinger from comment #13)
> Hi,
>
> just one question, how about the -m[no-]unaligned-access option?
>
> If -munaligned-access had been given the code was almost right,
> I mean AFAIK ldr/str should be handled in hardware but ldmia generates
> an alignment exception and _may_ be emulated by an IRQ handler,
> but that would not be very efficient.
>
> When -mno-unaligned-access is given any ldr/str on unaligned
> addresses have to be avoided.
Well, unfortunately -mno-unaligned-access does not provide any information to
the middle end. It's all handled in the ARM back end. So without directly
checking an ARM-specific option in the middle-end (evil), we don't have a good
solution for that. That's how I initially started looking at STRICT_ALIGNMENT,
which ARM and Sparc have in common.
However, since this is supposed to be an optimization and it is common for
misaligned memory accesses to suffer a penalty, I think it is better just to
not "optimize" when the memory access is misaligned, and leave it to the target
back ends to do their normal cleanups and workarounds.