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.