public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
@ 2013-06-26  8:46 ` jakub at gcc dot gnu.org
  2013-06-27 20:48 ` su at cs dot ucdavis.edu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-06-26  8:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-06-26
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.8.2
            Summary|wrong code at -O3 on        |[4.8/4.9 Regression] wrong
                   |x86_64-linux-gnu            |code at -O3 on
                   |                            |x86_64-linux-gnu
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
int u, a, b, c[2], d, *e, f, g;

int
foo (void)
{
  int t[1], i;
  for (i = 0; i < 1; i++)
    t[i] = 0;
  for (d = 0; d; d = 1)
    {
      int *s[1] = { &t[0] };
      g = a = *s[0];
    }
  f = g;
  return 1;
}

void
bar (void)
{
  for (; b < 2; b++)
    {
      int *p = &u;
      *p = 0;
      *p = foo ();
      e = &c[b];
      *e = 0;
    }
}

int
main ()
{
  bar ();
  if (u != 1)
    __builtin_abort ();
  return 0;
}

Started with r196174.  t is discovered unused during dce1 pass, but since
r196174 we no longer remove unused vars, which results in a t ={v} {CLOBBER};
stmt being kept inside of the loop and that for some reason affects lim1
decisions (something to investigate, potential code quality issue).
Anyway, sccp dump still looks good wrt. writes into u; already dse1 removes
the first u = 0; stmt, because it is redundant with following u = 1; in another
bb, but it keeps around u = 0; for the second iteration, so we first enter the
bb with u = 1; from there jump to bb with u = 0;, and from there go to the u =
1; bb back and finally goto exit.  In ldist it is already broken, so looks like
a ldist bug to me.


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
  2013-06-26  8:46 ` [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu jakub at gcc dot gnu.org
@ 2013-06-27 20:48 ` su at cs dot ucdavis.edu
  2013-06-29 17:58 ` mikpe at it dot uu.se
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-06-27 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zhendong Su <su at cs dot ucdavis.edu> ---
Hi Jakub, below are three additional (possibly related) testcases that may help
you folks diagnose the issue; they (including the original testcase) all
manifest differently: 

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

test #2: wrong code from both gcc trunk and 4.8 at -O3 in 32-bit mode only: 


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

int c, e[2], f, g, *l; 
long long h;

int foo ()
{
  int s[1];
  int i = 0;
  for (; i < 1; i++)
    s[0] = 0;
  h = 0;
  for (; h; h = 1) { 
    int *dp[1] = {&s[0]};
    *dp[0] = 0;
  }
  g = 0;
  return 0;
}

void bar ()
{
  for (; c < 2; c++) { 
    int *ip = &f;
    *ip = 0;
    *ip = 0 < foo (); 
    l = &e[c];
    *ip = 1;
    *l = 0;
  }
}

int main ()
{
  bar ();
  printf ("%d\n", f);
  return 0;
}

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

test #3: wrong code from gcc trunk (but not gcc 4.8) at -O3 in 32-bit mode
only: 


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

int f1;
int a, b, c; 
volatile int d;
int e[2], f, g; 
long long h;
int j, k, *l; 

short fn1 (unsigned short ui1)
{
  return ui1 - a;
}

int fn4 (int p)
{
  int s[1];
  int *tp = &f;
  int *cp = &g;
  int i = 0;
  for (; i < 1; i++)
    s[0] = 0;
  h = 0;
  for (; h; h = 1) { 
    int *dp[1] = {&s[0]};
    *dp[0] = 0;
  }
  *cp = p % (1 ^ *tp);
  return 0;
}

void
fn5 ()
{
  unsigned short t = 0;
  for (; c < 2; c++) { 
    int *ip = &f1;
    b = 0;
    j = 0;
    d ^ (*ip = 0); 
    t = fn1 (k);
    *ip = e[0] < fn4 (t);
    l = &e[c];
    *ip = 1;
    *l = 0;
  }
}

int
main ()
{
  fn5 ();
  printf ("%d\n", f1);
  return 0;
}

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

test #4: wrong code from gcc trunk (but not gcc 4.8) at -O3 in both 32-bit and
64-bit modes: 


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

int a;
int b;
int c;
volatile int d;
int e; 
int f[2];
int g;
int h;
int j;
int *k = &f[0];
int l;

short
fn1 (unsigned short p)
{
  return p * a;
}

int
fn2 (int p)
{
  int m[1];
  int i = 0;
  for (; i < 1; i++)
    m[0] = 0;
  g = 0; 
  for (; g; g = 1) {
    int *n[1] = {&m[0]};
  }
  l = p % (1 ^ *k);
  return 0;
}

int
main ()
{
  unsigned short o = 0;
  int *p;
  for (; c < 2; c++) {
    int *q = &e;
    b = 0;
    h = 0;
    d ^ (*q = 0);
    o = fn1 (j);
    *q = f[0] < fn2 (o);
    p = &f[c];
    *q = 1;
    fn2 (0);
    *p = 0;
  }
  printf ("%d\n", e);
  return 0;
}


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
  2013-06-26  8:46 ` [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu jakub at gcc dot gnu.org
  2013-06-27 20:48 ` su at cs dot ucdavis.edu
@ 2013-06-29 17:58 ` mikpe at it dot uu.se
  2013-06-29 20:17 ` mikpe at it dot uu.se
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mikpe at it dot uu.se @ 2013-06-29 17:58 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> ---
(In reply to Zhendong Su from comment #2)
> test #2: wrong code from both gcc trunk and 4.8 at -O3 in 32-bit mode only: 

The wrong-code for test #2 also started with r196174.


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2013-06-29 17:58 ` mikpe at it dot uu.se
@ 2013-06-29 20:17 ` mikpe at it dot uu.se
  2013-09-29 16:13 ` mikpelinux at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mikpe at it dot uu.se @ 2013-06-29 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Mikael Pettersson <mikpe at it dot uu.se> ---
(In reply to Zhendong Su from comment #2)
> test #4: wrong code from gcc trunk (but not gcc 4.8) at -O3 in both 32-bit
> and 64-bit modes: 

The wrong-code for test #4 also started with r198121.


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-06-29 20:17 ` mikpe at it dot uu.se
@ 2013-09-29 16:13 ` mikpelinux at gmail dot com
  2013-09-29 18:37 ` mikpelinux at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: mikpelinux at gmail dot com @ 2013-09-29 16:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Mikael Pettersson <mikpelinux at gmail dot com> ---
The wrong-code for tests #3 and #4 (both 4.9-only regressions) was fixed by
Richard's PR58223 patch in r202096.


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2013-09-29 16:13 ` mikpelinux at gmail dot com
@ 2013-09-29 18:37 ` mikpelinux at gmail dot com
  2013-10-16  9:51 ` jakub at gcc dot gnu.org
  2013-10-30 13:06 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: mikpelinux at gmail dot com @ 2013-09-29 18:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Mikael Pettersson <mikpelinux at gmail dot com> ---
The wrong-code for tests #1 and #2 (both 4.8/4.9 regressions) was also fixed
for 4.9 by Richard's PR58223 patch in r202096.  That patch has been backported
to 4.8 branch, and the tests do work with current 4.8.


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2013-09-29 18:37 ` mikpelinux at gmail dot com
@ 2013-10-16  9:51 ` jakub at gcc dot gnu.org
  2013-10-30 13:06 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-16  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.2                       |4.8.3

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.2 has been released.


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

* [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
       [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2013-10-16  9:51 ` jakub at gcc dot gnu.org
@ 2013-10-30 13:06 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-30 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Thus fixed.


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

end of thread, other threads:[~2013-10-30 13:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-57719-4@http.gcc.gnu.org/bugzilla/>
2013-06-26  8:46 ` [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu jakub at gcc dot gnu.org
2013-06-27 20:48 ` su at cs dot ucdavis.edu
2013-06-29 17:58 ` mikpe at it dot uu.se
2013-06-29 20:17 ` mikpe at it dot uu.se
2013-09-29 16:13 ` mikpelinux at gmail dot com
2013-09-29 18:37 ` mikpelinux at gmail dot com
2013-10-16  9:51 ` jakub at gcc dot gnu.org
2013-10-30 13:06 ` 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).