This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Unaligned access to packed structs on ppc405
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: Yaro Pollak <yarop at altair-semi dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 03 Feb 2006 23:25:33 -0500
- Subject: Re: Unaligned access to packed structs on ppc405
- References: <43E0A378.6060607@altair-semi.com>
>>>>> 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