This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode
- From: "su at cs dot ucdavis.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 08 Feb 2014 22:47:44 +0000
- Subject: [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60120
Bug ID: 60120
Summary: wrong code (for code with the optimize attribute) at
-Os on x86_64-linux-gnu in 32-bit mode
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The current gcc 4.8 branch miscompiles the following code that uses the
optimize attribute on x86_64-linux at -Os in 32-bit mode (but not 64-bit).
This is a regression from gcc 4.7.x and doesn't affect the current gcc trunk.
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/su/software/local/gcc-4.8/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8/configure --enable-languages=c,c++
Thread model: posix
gcc version 4.8.3 20140208 (prerelease) [gcc-4_8-branch revision 207632] (GCC)
$
$ gcc -m32 -O1 small.c; a.out
2
$ gcc -m64 -Os small.c; a.out
2
$ gcc -m32 -Os small.c; a.out
1
$
$ gcc-4.7.3 -m32 -Os small.c; a.out
2
$ gcc-trunk -m32 -Os small.c; a.out
2
$
--------------------------------
int printf (const char *, ...);
int a;
static int
fn1 (int p)
{
return p + 1;
}
static
__attribute__ ((optimize (1)))
int fn2 ()
{
for (; a < 1; a = fn1 (1))
;
return 0;
}
__attribute__ ((optimize (0)))
int fn3 ()
{
fn1 (0);
fn2 ();
return 0;
}
int
main ()
{
fn3 ();
printf ("%d\n", a);
return 0;
}