From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4984 invoked by alias); 4 Feb 2006 04:25:51 -0000 Received: (qmail 4959 invoked by uid 22791); 4 Feb 2006 04:25:50 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.watson.ibm.com (HELO igw2.watson.ibm.com) (129.34.20.6) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 04 Feb 2006 04:25:48 +0000 Received: from sp1n293en1.watson.ibm.com (sp1n293en1.watson.ibm.com [129.34.20.41]) by igw2.watson.ibm.com (8.12.11/8.13.1/8.13.1-2005-04-25 igw) with ESMTP id k144Ph3c001304; Fri, 3 Feb 2006 23:25:48 -0500 Received: from sp1n293en1.watson.ibm.com (localhost [127.0.0.1]) by sp1n293en1.watson.ibm.com (8.11.7-20030924/8.11.7/01-14-2004_2) with ESMTP id k144PdR219788; Fri, 3 Feb 2006 23:25:39 -0500 Received: from mgsmtp00.watson.ibm.com (mgsmtp00.watson.ibm.com [9.2.40.58]) by sp1n293en1.watson.ibm.com (8.11.7-20030924/8.11.7/01-14-2004_1) with ESMTP id k144PcX448160; Fri, 3 Feb 2006 23:25:38 -0500 Received: from makai.watson.ibm.com (makai.watson.ibm.com [9.2.216.144]) by mgsmtp00.watson.ibm.com (8.12.11/8.12.11/2005/09/01) with ESMTP id k145ObR4023818; Sat, 4 Feb 2006 00:24:37 -0500 Received: from watson.ibm.com (localhost [127.0.0.1]) by makai.watson.ibm.com (AIX5.1/8.11.6p2/8.11.0/03-06-2002) with ESMTP id k144PXD31312; Fri, 3 Feb 2006 23:25:34 -0500 Message-Id: <200602040425.k144PXD31312@makai.watson.ibm.com> To: Yaro Pollak cc: gcc-help@gcc.gnu.org Subject: Re: Unaligned access to packed structs on ppc405 References: <43E0A378.6060607@altair-semi.com> Date: Sat, 04 Feb 2006 04:25:00 -0000 From: David Edelsohn 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/msg00032.txt.bz2 >>>>> 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