http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45704

--- Comment #5 from Atsushi Nemoto <anemo at mba dot ocn.ne.jp> 2010-09-27 
15:48:32 UTC ---
Here is a similar test case with "packed" attribute, which still produces bad
result.
Four load-byte instructions are generated instead of one load-word.

struct st {
    int ptr;
} __attribute__ ((packed));

int foo(struct st *st)
{
    int v = *(volatile int *)&st->ptr;
    return v & 0xff;
}

gcc 4.4.4 works fine (same result with the first test case)

gcc 4.6.0 20100927 (or 4.5.2 20100927) generates:
    lbu    $2,0($4)
    lbu    $3,1($4)
    andi    $2,$2,0x00ff
    lbu    $3,2($4)
    lbu    $3,3($4)
    j    $31
    nop

I do not know this should be another PR or not.

Reply via email to