public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode
@ 2014-02-08 22:47 su at cs dot ucdavis.edu
  2014-02-08 22:55 ` [Bug ipa/60120] " su at cs dot ucdavis.edu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-02-08 22:47 UTC (permalink / raw)
  To: gcc-bugs

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;
}


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

end of thread, other threads:[~2014-02-10  9:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-08 22:47 [Bug ipa/60120] New: wrong code (for code with the optimize attribute) at -Os on x86_64-linux-gnu in 32-bit mode su at cs dot ucdavis.edu
2014-02-08 22:55 ` [Bug ipa/60120] " su at cs dot ucdavis.edu
2014-02-10  9:40 ` rguenth at gcc dot gnu.org
2014-02-10  9:42 ` rguenth at gcc dot gnu.org

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