This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21580] New: Less-than-ideal code generation for incrementing volatile variables
- From: "mrd at alkemio dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 May 2005 09:23:18 -0000
- Subject: [Bug c/21580] New: Less-than-ideal code generation for incrementing volatile variables
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
With gcc 4.0.1, the following code on i386 (using -O3 -fomit-frame-pointer):
int x;
void
foo (void)
{
++x;
}
compiles to:
foo:
incl x
ret
However, when x is changed to a volatile this instead compiles to:
foo:
movl x, %eax
incl %eax
movl %eax, x
ret
Similar degredations in the quality of generated code exists for statements like
--x, x += 2, etc when x is marked volatile. (Somewhat also related, "(void)x;"
still accesses memory when x is volatile -- I suppose this might be desirable,
however.)
--
Summary: Less-than-ideal code generation for incrementing
volatile variables
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mrd at alkemio dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21580