public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "anemo at mba dot ocn.ne.jp" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/45819] New: [4.5 Regression] unexpected unaligned access to volatile int Date: Tue, 28 Sep 2010 17:51:00 -0000 [thread overview] Message-ID: <bug-45819-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45819 Summary: [4.5 Regression] unexpected unaligned access to volatile int Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: anemo@mba.ocn.ne.jp An unexpected unaligned access instructions for volatile int are generated on gcc 4.5 or 4.6 with this test case. struct st { int ptr; } __attribute__ ((packed)); int foo(struct st *st) { int v = *(volatile int *)&st->ptr; return v; } This test case is derived from something like this in ARM linux kernel. struct st { unsigned int ptr; } __attribute__ ((packed)); unsigned int foo(struct st *st) { return readl(&st->ptr); } mipsel-linux-gcc-4.5.1 -O2 foo.c -S output: lwl $2,3($4) nop lwr $2,0($4) j $31 nop arm-linux-gnueabi-gcc-4.5.1 -O2 foo.c -S output: ldrb r3, [r0, #0] @ zero_extendqisi2 ldrb r1, [r0, #1] @ zero_extendqisi2 ldrb r2, [r0, #2] @ zero_extendqisi2 orr r3, r3, r1, asl #8 ldrb r0, [r0, #3] @ zero_extendqisi2 orr r3, r3, r2, asl #16 orr r0, r3, r0, asl #24 bx lr It seems the cast is ignored and unaligned access is assumed. gcc 4.4.4 works fine. mipsel-linux-gcc-4.4.4 -O2 foo.c -S output: lw $2,0($4) j $31 nop arm-linux-gnueabi-gcc-4.4.4 -O2 foo.c -S output: ldr r0, [r0, #0] bx lr The similar problem was found as PR 45704. git-bisect tell me same commit 0d9f1189f3df5ce5c0efc3ecadc7c0a4f75b202d is the first bad commit. Like PR 45704, reverting this change fixes this problme too. - STRIP_USELESS_TYPE_CONVERSION (sub); + STRIP_NOPS (sub); But the final fix for PR 45704 does not fix this problem. mipsel-linux-gcc (4.6.0 20100927): lbu $5,0($4) lbu $6,1($4) lbu $3,2($4) andi $6,$6,0x00ff lbu $2,3($4) andi $5,$5,0x00ff sll $6,$6,8 andi $3,$3,0x00ff or $4,$6,$5 sll $3,$3,16 or $3,$3,$4 sll $2,$2,24 j $31 or $2,$2,$3 arm-linux-gnueabi-gcc (4.6.0 20100927): ldrb r3, [r0, #0] @ zero_extendqisi2 ldrb r1, [r0, #1] @ zero_extendqisi2 ldrb r2, [r0, #2] @ zero_extendqisi2 orr r3, r3, r1, asl #8 ldrb r0, [r0, #3] @ zero_extendqisi2 orr r3, r3, r2, asl #16 orr r0, r3, r0, asl #24 bx lr
next reply other threads:[~2010-09-28 15:30 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-09-28 17:51 anemo at mba dot ocn.ne.jp [this message] 2010-09-28 18:38 ` [Bug c/45819] " rguenth at gcc dot gnu.org 2010-09-28 19:53 ` anemo at mba dot ocn.ne.jp 2010-09-30 10:00 ` [Bug middle-end/45819] " anemo at mba dot ocn.ne.jp 2010-09-30 11:56 ` rguenth at gcc dot gnu.org 2010-11-12 15:11 ` rguenth at gcc dot gnu.org 2010-11-24 14:43 ` anemo at mba dot ocn.ne.jp 2010-12-16 13:07 ` rguenth at gcc dot gnu.org 2011-02-22 13:40 ` anemo at mba dot ocn.ne.jp 2011-04-28 14:57 ` rguenth at gcc dot gnu.org 2011-06-09 6:47 ` raj.khem at gmail dot com 2011-07-22 9:50 ` rguenth at gcc dot gnu.org 2011-07-22 11:55 ` rguenth at gcc dot gnu.org 2011-07-22 12:20 ` rguenth at gcc dot gnu.org 2011-07-22 12:20 ` rguenth at gcc dot gnu.org 2011-07-22 12:22 ` rguenth at gcc dot gnu.org 2011-07-22 12:25 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-45819-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).