From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7308 invoked by alias); 5 Feb 2006 18:35:57 -0000 Received: (qmail 7300 invoked by uid 22791); 5 Feb 2006 18:35:57 -0000 X-Spam-Check-By: sourceware.org Received: from mr1.netezza.com (HELO mail2.netezza.com) (12.148.248.137) by sourceware.org (qpsmtpd/0.31) with SMTP; Sun, 05 Feb 2006 18:35:55 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: Unaligned access to packed structs on ppc405 Date: Sun, 05 Feb 2006 18:35:00 -0000 Message-ID: <4D87F853B8020F4888896B1507DC0F09026798@mail2.netezza.com> From: "John Yates" To: "David Edelsohn" , "Yaro Pollak" Cc: Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-02/txt/msg00043.txt.bz2 David, Do I read this correctly? Are you truly saying that two structs with identical layout will trigger different code sequences just because one was declared packed? (This is just the sort of thing that drives me crazy when trying to coax a compiler into producing good code.) /john -----Original Message----- From: David Edelsohn [mailto:dje@watson.ibm.com] Sent: Friday, February 03, 2006 11:26 PM To: Yaro Pollak Cc: gcc-help@gcc.gnu.org Subject: Re: Unaligned access to packed structs on ppc405 >>>>> Yaro Pollak writes: > If on the other hand I compile: >=20 > Test pt; > return pt.b + pt.c + pt.d; >=20 > 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.=20 David