From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15860 invoked by alias); 20 Nov 2007 12:57:00 -0000 Received: (qmail 15413 invoked by uid 48); 20 Nov 2007 12:56:36 -0000 Date: Tue, 20 Nov 2007 12:57:00 -0000 Subject: [Bug c/34161] New: -Os produces 32-bit load from 16-bit variable X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "vegard at peltkore dot net" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg01905.txt.bz2 When compiling the following program with -Os, the short member x of struct a is read using a movl instruction instead of movzwl. struct a { int dummy; short x; }; struct b { unsigned short x; }; extern void dummy(struct b *b); void f(struct a *a, struct b *b) { dummy(b); if (a) { asm("/* THIS FIELD IS ONLY 16 BITS */"); b->x = a->x; } } With -O3: movzwl 4(%ebx), %eax movw %ax, (%esi) And -Os: movl 4(%ebx), %eax movw %ax, (%esi) -- Summary: -Os produces 32-bit load from 16-bit variable Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vegard at peltkore dot net GCC build triplet: i386-redhat-linux GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34161