public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/65449] New: -fstrict-volatile-bitfields affects volatile pointer dereference and produce wrong codes
@ 2015-03-17  9:28 ma.jiang at zte dot com.cn
  2015-03-18 12:12 ` [Bug middle-end/65449] " bernd.edlinger at hotmail dot de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ma.jiang at zte dot com.cn @ 2015-03-17  9:28 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2015-03-20  2:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17  9:28 [Bug middle-end/65449] New: -fstrict-volatile-bitfields affects volatile pointer dereference and produce wrong codes ma.jiang at zte dot com.cn
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

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).