home *** CD-ROM | disk | FTP | other *** search
- >> EG, to access bytes
- >> 12 and 13 only of a structure, GCC will use by default:
- >> ldr r0, [r1, #14]
- >> mov r0, r0, lsr #16
- >
- > >Does anyone know if this is a legal optimisation that the compiler is making?
- >
- > The consensus among the gcc people is that it is, because the ARM ABI is
- > allowed to define a minimum alignment (and has done so, to 32). The
- > optimisation does produce noticeably better code in the vast majority of cases.
- >
- > A way to signal to gcc that a structure is unaligned in this way is on the
- > cards in the future, but we don't have it yet. In the short term we need to
- > find a workaround such as using -mshort-load-bytes on the offending source
- > files, or fixing them to use explicit byte ops.
-
- Can I ask for a specific example here? Are we talking about something along
- the lines of:
-
- struct foo
- {
- int a;
- short b;
- short c;
- char d;
- short e;
- short f;
- }
-
- ie which of these will be wrongly accessed? And what alignment will GCC
- give them?
-
- I don't think that -mshort-load-bytes is the correct way to differentiate
- the two cases, I think -munaligned-loads versus -mno-unaligned-loads is the
- correct name for the switch - simply because I don't think shorts should
- be loaded as bytes! It's /at least/ as efficient to load them as words
- and then shift them twice as it is to load as bytes and orr them together.
-
- unsubscribe: body of `unsubscribe linux-arm' to majordomo@vger.rutgers.edu
-
-