public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/34161]  New: -Os produces 32-bit load from 16-bit variable
@ 2007-11-20 12:57 vegard at peltkore dot net
  2007-11-20 15:41 ` [Bug c/34161] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vegard at peltkore dot net @ 2007-11-20 12:57 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-05  9:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-20 12:57 [Bug c/34161] New: -Os produces 32-bit load from 16-bit variable vegard at peltkore dot net
2007-11-20 15:41 ` [Bug c/34161] " rguenth at gcc dot gnu dot org
2007-11-21 11:05 ` [Bug target/34161] " vegard at peltkore dot net
2007-11-21 13:06 ` manu at gcc dot gnu dot org
2008-02-05  9:24 ` vegard dot nossum at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).