This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33102] New: volatile excessively suppresses optimizations in range checks
- From: "paulmck at linux dot vnet dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Aug 2007 23:52:58 -0000
- Subject: [Bug c/33102] New: volatile excessively suppresses optimizations in range checks
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Source code:
--------------
volatile int i;
int j;
int testme(void)
{
return i <= 1;
}
int testme2(void)
{
return j <= 1;
}
--------------
Compiler command line: "cc -S -O torvalds.c"
--------------
Expected results: volatile accesses not moved past sequence points,
optimization otherwise unaffected.
--------------
Observed results: redundant move to register generated, unecessarily increasing
register pressure, increasing the size of the binary, and potentially consuming
more power and decreasing performance.
--------------
Build date and platform: August 17 2007 Ubuntu Feisty Fawn.
--------------
gcc -v output:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
--------------
Code generated to compare volatile variable to constant:
movl i, %eax
cmpl $1, %eax
Code generated to compare non-volatile variable to constant:
cmpl $1, j
The latter code sequence should be generated for the volatile case as well as
the non-volatile case. Similar inefficiencies are produced in response to
other uses of volatile variables.
--
Summary: volatile excessively suppresses optimizations in range
checks
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: paulmck at linux dot vnet dot ibm dot com
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33102