Unaligned access to packed structs on ppc405
David Edelsohn
dje@watson.ibm.com
Sat Feb 4 04:25:00 GMT 2006
>>>>> Yaro Pollak writes:
> If on the other hand I compile:
>
> Test pt;
> return pt.b + pt.c + pt.d;
>
> lwz 3,8(1)
That is an artifact of the example. If I declare "pt" as a global
variable, GCC 4.1 prerelease produces three lbz.
The lbz has to do with the size and the packed alignment. With
the packed structure, GCC chooses the smallest memory access that covers
the bitfield. Once GCC has chosen bytes, it cannot merge the loads
together. If the structure were not declared packed, GCC would use wider
loads with masking, and then determine that the loads refer to the same
object.
David
More information about the Gcc-help
mailing list