public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ma.jiang at zte dot com.cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/65449] New: -fstrict-volatile-bitfields affects volatile pointer dereference and produce wrong codes Date: Tue, 17 Mar 2015 09:28:00 -0000 [thread overview] Message-ID: <bug-65449-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65449 Bug ID: 65449 Summary: -fstrict-volatile-bitfields affects volatile pointer dereference and produce wrong codes Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: ma.jiang at zte dot com.cn Hi,all. It seems that -fstrict-volatile-bitfields can affect volatile pointer dereference. However, the gcc manual said this option should only affect accesse to bit-fields or structure fields. Compiling the test case: char mt[20]; void main() { void *mm=&(mt[1]); *((volatile int *)mm)=4; } with -O2 -mstrict-align -fstrict-volatile-bitfields on PPC. We can see that "*((volatile int *)mm)=4 " is done by a single stw. Beware that -mstrict-align means a non-aligned memory access is disallowed, and &(mt[1]) is obviously not a address aligned to 4-bytes boundary. The compiler should have no reasons to produce a unaligned stw when mstric-align is on. Further more,compiling with -O2 -mstrict-align -fno-strict-volatile-bitfields, the compiler will produce four lbz/stb pairs for "*((volatile int *)mm)=4;". This is ridiculous as the C standard does not require the read, and surely no performance benefits could grain from these lbz.
next reply other threads:[~2015-03-17 9:28 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-17 9:28 ma.jiang at zte dot com.cn [this message] 2015-03-18 12:12 ` [Bug middle-end/65449] " bernd.edlinger at hotmail dot de 2015-03-19 10:03 ` ma.jiang at zte dot com.cn 2015-03-19 14:33 ` bernd.edlinger at hotmail dot de 2015-03-20 5:14 ` ma.jiang at zte dot com.cn
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-65449-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).