public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu
@ 2013-10-10  5:10 su at cs dot ucdavis.edu
  2013-10-10 11:51 ` [Bug middle-end/58677] " mikpelinux at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-10-10  5:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58677
           Summary: wrong code at -O1 on x86_64-linux-gnu
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the attached testcase on x86_64-linux at
(only) -O1 in 64-bit mode. 

This is a regression from 4.8.x.

This one was quite tough to reduce. The attached testcase is the best I was
able to get so far. 


$ 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 20131009 (experimental) [trunk revision 203302] (GCC) 
$ 
$ gcc-trunk -O0 small.c; a.out
0
0
1
$ gcc-4.8 -O1 small.c; a.out
0
0
1
$ gcc-trunk -m32 -O1 small.c; a.out
0
0
1
$ clang-trunk -O1 small.c; a.out
0
0
1
$ gcc-trunk -O1 small.c; a.out
0
0
0
$ 


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


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

#pragma pack(1)
struct S
{
  unsigned int f0:7;
  int f1:19;
  unsigned int f2:22;
  int f3:25;
} k[6][8];

int a, b, c, e, h, l, m, n, o, *p = &h, **q = &p, r, s;
unsigned int d[256];

static void
fn1 ()
{
  for (a = 0; a < 256; a++)
    d[a] = a;
}

static void
fn2 (unsigned int p1, char *p2, int p3)
{
  e = d[e ^ p1];
  printf ("%s%X\n", p2, e);
}

static int *
fn3 (int p1, int p2)
{
  for (s = 10; s > 2; s = -6)
    for (r = 0; r < 6; r++)
      for (n = 0; n < 8; n++)
    {
      struct S t = { 1, -195, 321, 4857 };
      k[r][n] = t;
    }
  return *q;
}

static int
fn4 ()
{
  *q = fn3 (l, b);
  return c;
}

int
main (int argc, char *argv[])
{
  int v = 0;
  if (argc == 2)
    v = 1;
  fn1 ();
  fn4 ();
  fn2 (m, "", v);
  fn2 (o, "", v);
  fn2 (k[0][0].f0, "", v);
  return 0;
}


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

* [Bug middle-end/58677] wrong code at -O1 on x86_64-linux-gnu
  2013-10-10  5:10 [Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2013-10-10 11:51 ` mikpelinux at gmail dot com
  2013-10-10 12:02 ` rguenth at gcc dot gnu.org
  2013-10-10 15:19 ` su at cs dot ucdavis.edu
  2 siblings, 0 replies; 4+ messages in thread
From: mikpelinux at gmail dot com @ 2013-10-10 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Started with r202525 (PR58404 missed-optimization fix), stopped with r203315
(PR58570 wrong-code fix).  The cause of PR58570 was not r202525.

Can you check if the original testcase works on current trunk?


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

* [Bug middle-end/58677] wrong code at -O1 on x86_64-linux-gnu
  2013-10-10  5:10 [Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-10-10 11:51 ` [Bug middle-end/58677] " mikpelinux at gmail dot com
@ 2013-10-10 12:02 ` rguenth at gcc dot gnu.org
  2013-10-10 15:19 ` su at cs dot ucdavis.edu
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-10 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Mikael Pettersson from comment #1)
> Started with r202525 (PR58404 missed-optimization fix), stopped with r203315
> (PR58570 wrong-code fix).  The cause of PR58570 was not r202525.
> 
> Can you check if the original testcase works on current trunk?

But r202525 will expose more opportunities for the code with the bug
that was fixed by r203315 so it makes sense.

*** This bug has been marked as a duplicate of bug 58570 ***


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

* [Bug middle-end/58677] wrong code at -O1 on x86_64-linux-gnu
  2013-10-10  5:10 [Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-10-10 11:51 ` [Bug middle-end/58677] " mikpelinux at gmail dot com
  2013-10-10 12:02 ` rguenth at gcc dot gnu.org
@ 2013-10-10 15:19 ` su at cs dot ucdavis.edu
  2 siblings, 0 replies; 4+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-10-10 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Mikael Pettersson from comment #1)
> Started with r202525 (PR58404 missed-optimization fix), stopped with r203315
> (PR58570 wrong-code fix).  The cause of PR58570 was not r202525.
> 
> Can you check if the original testcase works on current trunk?

Just checked; it works. Thanks.


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

end of thread, other threads:[~2013-10-10 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-10  5:10 [Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu su at cs dot ucdavis.edu
2013-10-10 11:51 ` [Bug middle-end/58677] " mikpelinux at gmail dot com
2013-10-10 12:02 ` rguenth at gcc dot gnu.org
2013-10-10 15:19 ` su at cs dot ucdavis.edu

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