This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34161] New: -Os produces 32-bit load from 16-bit variable
- From: "vegard at peltkore dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Nov 2007 12:56:36 -0000
- Subject: [Bug c/34161] New: -Os produces 32-bit load from 16-bit variable
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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