public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/59058] New: wrong code at -O3 on x86_64-linux-gnu (affecting gcc 4.6 to trunk)
@ 2013-11-09  4:52 su at cs dot ucdavis.edu
  2013-11-09  8:48 ` [Bug tree-optimization/59058] " glisse at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-11-09  4:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59058

            Bug ID: 59058
           Summary: wrong code at -O3 on x86_64-linux-gnu (affecting gcc
                    4.6 to trunk)
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk (as well as 4.6, 4.7, and 4.8) miscompiles the following
code on x86_64-linux-gnu at -O3 in both 32-bit and 64-bit modes. 

It also affects gcc 4.6 and 4.7 at -O2, older versions of gcc, and on other
platforms. 

For trunk and 4.8 (but not for 4.6 and 4.7 though), -fno-tree-vectorize makes
the bug go away. 

Interestingly also, both the current clang and icc fail on this testcase too. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131108 (experimental) [trunk revision 204593] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
-1
$ gcc-trunk -O3 small.c; a.out
7
$ gcc-4.8.2 -O3 small.c; a.out
7
$ gcc-4.7.3 -O3 small.c; a.out
131071
$ gcc-4.7.3 -O2 small.c; a.out
131071
$ gcc-4.6.4 -O3 small.c; a.out
131071
$ gcc-4.6.4 -O2 small.c; a.out
131071
$ 
$ gcc-trunk -O3 -fno-tree-vectorize small.c; a.out
-1
$ gcc-4.8.2 -O3 -fno-tree-vectorize small.c; a.out
-1
$ gcc-4.7.3 -O3 -fno-tree-vectorize small.c; a.out
131071
$ gcc-4.6.4 -O3 -fno-tree-vectorize small.c; a.out
131071
$
$ clang-trunk -O3 small.c; a.out
0
$ icc -O3 small.c; a.out
1
$ 


--------------------------------------


int printf (const char *, ...);

int a, c, d;
short b = -1; 

void 
foo ()
{
  b++;
}

void 
bar ()
{
l1:
  foo ();
  d = -3;
  for (a = 0; a > -3; a = d)
    c |= b;
  if (b)
    goto l1;
}

int 
main ()
{
  b++;
l2:
  if (b)
    goto l2;
  bar ();
  printf ("%d\n", c);
  return 0;
}


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

end of thread, other threads:[~2015-06-23  8:45 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-09  4:52 [Bug tree-optimization/59058] New: wrong code at -O3 on x86_64-linux-gnu (affecting gcc 4.6 to trunk) su at cs dot ucdavis.edu
2013-11-09  8:48 ` [Bug tree-optimization/59058] " glisse at gcc dot gnu.org
2013-11-11 15:48 ` [Bug tree-optimization/59058] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-11-19 15:05 ` rguenth at gcc dot gnu.org
2013-11-20 11:45 ` rguenth at gcc dot gnu.org
2013-11-20 12:08 ` rguenth at gcc dot gnu.org
2013-11-20 12:28 ` rguenth at gcc dot gnu.org
2013-11-20 13:07 ` rguenth at gcc dot gnu.org
2013-11-20 13:50 ` rguenth at gcc dot gnu.org
2013-11-21  9:15 ` rguenth at gcc dot gnu.org
2013-11-21 14:09 ` rguenth at gcc dot gnu.org
2013-12-03 16:31 ` jakub at gcc dot gnu.org
2013-12-03 18:50 ` rguenther at suse dot de
2013-12-06  9:23 ` rguenth at gcc dot gnu.org
2013-12-06 12:42 ` [Bug tree-optimization/59058] [4.7/4.8 " rguenth at gcc dot gnu.org
2014-06-12 13:48 ` rguenth at gcc dot gnu.org
2014-12-19 13:42 ` [Bug tree-optimization/59058] [4.8 " jakub at gcc dot gnu.org
2015-06-23  8:45 ` 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).