[Bug rtl-optimization/57417] New: hang on volatile int array

2013-05-25 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57417

Bug ID: 57417
   Summary: hang on volatile int array
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes gcc trunk (and the 4.7 & 4.8 branches) to hang at -O1
or above. This seems to be different from 57381, but perhaps related.

$ gcc-trunk -v
Target: x86_64-unknown-linux-gnu
gcc version 4.9.0 20130525 (experimental) [trunk revision 199323] (GCC)
$ gcc-trunk -m32 -O0 -c small.c
$ gcc-trunk -m32 -O1 -c small.c
^C
$ cat small.c
int a, b, c;

void foo ()
{
  volatile int d[1];
  b = 0;
  for (;; a--)
c = (int)&d[b];
}


[Bug tree-optimization/57718] New: ICE in execute_todo, passes.c:2002 at -O3 (both -m32 & -m64)

2013-06-25 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57718

Bug ID: 57718
   Summary: ICE in execute_todo, passes.c:2002 at -O3 (both -m32 &
-m64)
   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

With current gcc trunk on x86_64-linux, the following code causes an ICE when
compiled at -O3 (both -m32 and -m64). This is a regression from 4.8.x. 

It may be related to 57592. 

$ gcc-trunk -v
gcc version 4.9.0 20130625 (experimental) [trunk revision 200388] (GCC) 
$ gcc-trunk -O2 -c reduced.c
$ gcc-4.8 -O3 -c reduced.c
$ gcc-trunk -O3 -c reduced.c
reduced.c: In function ‘foo’:
reduced.c:3:6: internal compiler error: Segmentation fault
 void foo ()
  ^
0x7d729f crash_signal
../../gcc-trunk/gcc/toplev.c:333
0x7ff31b ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:314
0x7ff5e0 get_or_create_ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:362
0x8187fa get_reaching_def
../../gcc-trunk/gcc/tree-into-ssa.c:1184
0x81e96b maybe_replace_use
../../gcc-trunk/gcc/tree-into-ssa.c:1784
0x81e96b rewrite_update_stmt
../../gcc-trunk/gcc/tree-into-ssa.c:1967
0x81e96b rewrite_update_enter_block
../../gcc-trunk/gcc/tree-into-ssa.c:2136
0xb3801a walk_dominator_tree(dom_walk_data*, basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:210
0x817503 rewrite_blocks
../../gcc-trunk/gcc/tree-into-ssa.c:2216
0x81dc1e update_ssa(unsigned int)
../../gcc-trunk/gcc/tree-into-ssa.c:3303
0x74a3db execute_function_todo
../../gcc-trunk/gcc/passes.c:1942
0x74ab7e execute_todo
../../gcc-trunk/gcc/passes.c:2002
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

--

int a, b, c, d, e, f;

void foo ()
{
  int g;
  for (;;) {
f = 0;
for (; f <= 1; f++) {
  a = 0;
  for (; a <= 4; a++)
b |= a >= g;
  if (d)
continue;
  e = 0;
}
c = bar () < b;
  }
}

[Bug tree-optimization/57719] New: wrong code at -O3 on x86_64-linux-gnu

2013-06-25 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57719

Bug ID: 57719
   Summary: wrong code at -O3 on x86_64-linux-gnu
   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

Current gcc trunk (and gcc-4.8) produces wrong code for the following testcase
on x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. This is a
regression from 4.7.x.

$ gcc-trunk -v
gcc version 4.9.0 20130625 (experimental) [trunk revision 200388] (GCC) 
$ gcc-trunk -O2 reduced.c  
$ a.out
1
$ gcc-4.7 -O3 reduced.c
$ a.out
1
$ gcc-4.8 -O3 reduced.c
$ a.out
0
$ gcc-trunk -O3 reduced.c
$ a.out
0

-

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

int u; 

int a, b, c[2], d, *e, f, g; 

int fn2 ()
{
  int t[1];
  int i;
  i = 0;
  for (; 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 fn1 ()
{
  for (; b < 2; b++) {
int *p = &u; 
*p = 0;
*p = fn2();
e = &c[b];
*e = 0;
  }
}

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


[Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-06-27 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57719

--- Comment #2 from Zhendong Su  ---
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;
}


[Bug middle-end/57859] New: -ftrapv does not trap on signed overflows for struct fields (32-bit mode)

2013-07-09 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57859

Bug ID: 57859
   Summary: -ftrapv does not trap on signed overflows for struct
fields (32-bit mode)
   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 following code (which has a signed integer overflow) doesn't trap when
compiled at -O1 or above with -ftrapv on x86_64-linux. This applies to the
current gcc trunk, as well as gcc-4.6, gcc-4.7, and gcc-4.8. 

$ gcc-trunk -v
gcc version 4.9.0 20130708 (experimental) [trunk revision 200751] (GCC) 
$ gcc-trunk -m32 -O0 -ftrapv small.c
$ a.out
Aborted (core dumped)
$ gcc-trunk -m32 -O1 -ftrapv small.c  
$ a.out
$ gcc-4.8 -m32 -O1 -ftrapv small.c
$ a.out
$ gcc-4.7 -m32 -O1 -ftrapv small.c
$ a.out
$ gcc-4.6 -m32 -O1 -ftrapv small.c
$ a.out
$ 


---


struct S
{
  int f;
}; 

int
main ()
{
  struct S s; 
  for (s.f = 1; s.f > 0; ++s.f)
; 
  return 0;
}


---

The following code does trap in 32-bit mode (but still not in 64-bit): 

int
main ()
{
  int i; 
  for (i = 1; i > 0; ++i)
; 
  return 0;
}


[Bug tree-optimization/57860] New: wrong code for bitwise ops with long long literal on x86_64-linux (32-bit mode)

2013-07-09 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57860

Bug ID: 57860
   Summary: wrong code for bitwise ops with long long literal on
x86_64-linux (32-bit mode)
   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 mis-compiles the following code on x86_64-linux at -O2
and -O3 in 32-bit mode. This is a regression from 4.8.x. 

$ gcc-trunk -v
gcc version 4.9.0 20130708 (experimental) [trunk revision 200751] (GCC) 
$ gcc-trunk -m32 -O2 reduced.c
$ a.out
0
$ gcc-trunk -m32 -O3 reduced.c
$ a.out
0
$ gcc-trunk -m32 -O0 reduced.c
$ a.out
1
$ gcc-4.8 -m32 -O2 reduced.c
$ a.out
1
$ 





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

int a, *b = &a, c, d, e, *f = &e, g, *h = &d, k[1] = {1};

int
foo (int p)
{
  for (;; g++)
{
  for (; c; c--);
  *f = *h = p > ((0x1LL ^ a) & *b);
  if (k[g])
return 0;
}
}

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


[Bug tree-optimization/57861] New: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode

2013-07-09 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57861

Bug ID: 57861
   Summary: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode
   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 produces wrong code for the following testcase on
x86_64-linux when compiled at -O3 in 32-bit mode. This is a regression from
4.8.x.

$ gcc-trunk -v
gcc version 4.9.0 20130708 (experimental) [trunk revision 200751] (GCC) 
$ gcc-trunk -m32 -O3 reduced.c
$ a.out
1
$ gcc-trunk -m32 -O2 reduced.c
$ a.out
0
$ gcc-4.8 -m32 -O3 reduced.c
$ a.out
0
$ 





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

short a = 1, f;
int b, c, d, *g = &b, h, i, j;
unsigned int e;

static int
foo (char p)
{
  int k;
  for (c = 0; c < 2; c++)
{
  i = (j = 0) || p;
  k = i * p;
  if (e < k)
{
  short *l = &f;
  a = d && h;
  *l = 0;
}
}
  return 0;
}

int
main ()
{
  *g = foo (a);
  printf ("%d\n", a);
  return 0;
}


[Bug tree-optimization/57875] New: wrong code at -O2 on x86_64-linux-gnu in 32-bit mode

2013-07-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57875

Bug ID: 57875
   Summary: wrong code at -O2 on x86_64-linux-gnu in 32-bit mode
   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 mis-compiles the following code on x86_64-linux at -O2 in
32-bit mode. This is a regression from 4.8.x. 

$ gcc-trunk -v
gcc version 4.9.0 20130710 (experimental) [trunk revision 200864] (GCC) 
$
$ gcc-trunk -m32 -O2 small.c
$ a.out
1
$ gcc-trunk -m32 -O1 small.c
$ a.out
0
$ gcc-trunk -m32 -O3 small.c
$ a.out
0
$ gcc-4.8 -m32 -O2 small.c
$ a.out
0
$ 





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

int a[1], b, c, d, f, i; 
char e[1];

int
main ()
{
  for (; i < 1; i++)
if (!d) {
  if (!c) 
f = 2;
  e[0] &= f ^= 0;
}
  b = a[e[0] >> 1 & 1];
  printf ("%d\n", b);
  return 0;
}


[Bug tree-optimization/57876] New: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode

2013-07-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57876

Bug ID: 57876
   Summary: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode
   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 mis-compiles the following code on x86_64-linux at -O3 in
32-bit mode. This is a regression from 4.8.x. 

$ gcc-trunk -v   
gcc version 4.9.0 20130710 (experimental) [trunk revision 200864] (GCC) 
$
$ gcc-trunk -m32 -O3 small.c
$ a.out
0
$ gcc-trunk -m32 -O2 small.c
$ a.out
1
$ gcc-4.8 -m32 -O3 small.c
$ a.out
1
$ 





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

int a, b = 1, c, *d = &c, f, *g, h, j;
static int e;

int
main ()
{
  int i;
  for (i = 0; i < 2; i++)
{
  long long k = b;
  int l;
  for (f = 0; f < 8; f++)
{
  int *m = &e;
  j = *d;
  h = a * j - 1;
  *m = (h == 0) < k;
  g = &l;
}
}
  printf ("%d\n", e);
  return 0;
}


[Bug tree-optimization/57877] New: wrong code at -Os on x86_64-linux-gnu in 32-bit mode

2013-07-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57877

Bug ID: 57877
   Summary: wrong code at -Os on x86_64-linux-gnu in 32-bit mode
   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 mis-compiles the following code on x86_64-linux at -Os in
32-bit mode. This is a regression from 4.8.x. 

$ gcc-trunk -v   
gcc version 4.9.0 20130710 (experimental) [trunk revision 200864] (GCC) 
$ 
$ gcc-trunk -m32 -Os small.c
$ a.out
0
$ gcc-trunk -m32 -O3 small.c
$ a.out
1
$ gcc-4.8 -m32 -Os small.c
$ a.out
1
$ 


-


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

int a, b, *c = &b, e, f = 6, g, h;
short d;

static unsigned char
foo (unsigned long long p1, int *p2)
{
  for (; g <= 0; g++)
{
  short *i = &d;
  int *j = &e;
  h = *c;
  *i = h;
  *j = (*i == *p2) < p1;
}
  return 0;
}

int
main ()
{
  foo (f, &a);
  printf ("%d\n", e);
  return 0;
}


[Bug c/57923] New: ICE in handle_braces (gcc.c) at -O3 (both 32-bit and 64-bit modes)

2013-07-18 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57923

Bug ID: 57923
   Summary: ICE in handle_braces (gcc.c) at -O3 (both 32-bit and
64-bit modes)
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux (both 32-bit and 64-bit modes). This is a regression from
4.8.x.

$ gcc-trunk -v
gcc version 4.9.0 20130718 (experimental) [trunk revision 201019] (GCC) 
$ gcc-trunk -O2 -c small.c
$ gcc-4.8 -O3 -c small.c
$ gcc-trunk -O3 small.c
gcc-trunk: internal compiler error: Segmentation fault (program cc1)
0x40c95d execute
../../gcc-trunk/gcc/gcc.c:2824
0x40ccb4 do_spec_1
../../gcc-trunk/gcc/gcc.c:4616
0x40f841 process_brace_body
../../gcc-trunk/gcc/gcc.c:5873
0x40f841 handle_braces
../../gcc-trunk/gcc/gcc.c:5787
0x40d3ea do_spec_1
../../gcc-trunk/gcc/gcc.c:5270
0x40f841 process_brace_body
../../gcc-trunk/gcc/gcc.c:5873
0x40f841 handle_braces
../../gcc-trunk/gcc/gcc.c:5787
0x40d3ea do_spec_1
../../gcc-trunk/gcc/gcc.c:5270
0x40cf3b do_spec_1
../../gcc-trunk/gcc/gcc.c:5375
0x40f841 process_brace_body
../../gcc-trunk/gcc/gcc.c:5873
0x40f841 handle_braces
../../gcc-trunk/gcc/gcc.c:5787
0x40d3ea do_spec_1
../../gcc-trunk/gcc/gcc.c:5270
0x40f841 process_brace_body
../../gcc-trunk/gcc/gcc.c:5873
0x40f841 handle_braces
../../gcc-trunk/gcc/gcc.c:5787
0x40d3ea do_spec_1
../../gcc-trunk/gcc/gcc.c:5270
0x40f841 process_brace_body
../../gcc-trunk/gcc/gcc.c:5873
0x40f841 handle_braces
../../gcc-trunk/gcc/gcc.c:5787
0x40d3ea do_spec_1
../../gcc-trunk/gcc/gcc.c:5270
0x40f841 process_brace_body
../../gcc-trunk/gcc/gcc.c:5873
0x40f841 handle_braces
../../gcc-trunk/gcc/gcc.c:5787
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


-

char a;

foo (int **p)
{
  int b;
  for (;;) {
int c[1] = {};
unsigned *d = &c[0];
for (b=7; b; b--)
  **p &= --*d >= a;
  }
}
$


[Bug tree-optimization/58018] New: ICE in tree_ssa_unswitch_loops at -O3

2013-07-28 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58018

Bug ID: 58018
   Summary: ICE in tree_ssa_unswitch_loops at -O3
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux in both 32-bit and 64-bit modes. This is a regression from
4.8.x.

$ gcc-trunk -v
gcc version 4.9.0 20130728 (experimental) [trunk revision 201291] (GCC) 
$ gcc-trunk -O2 -c small.c
$ gcc-4.8 -O3 -c small.c
$ gcc-trunk -O3 -c small.c
small.c: In function ‘foo’:
small.c:9:6: internal compiler error: Segmentation fault
 void foo ()
  ^
0x7d4c4f crash_signal
../../gcc-trunk/gcc/toplev.c:334
0x7fccdb ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:314
0x7fcfa0 get_or_create_ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:362
0x81623a get_reaching_def
../../gcc-trunk/gcc/tree-into-ssa.c:1184
0x81c39a maybe_replace_use
../../gcc-trunk/gcc/tree-into-ssa.c:1784
0x81c39a rewrite_update_stmt
../../gcc-trunk/gcc/tree-into-ssa.c:1967
0x81c39a rewrite_update_enter_block
../../gcc-trunk/gcc/tree-into-ssa.c:2136
0xb3670a walk_dominator_tree(dom_walk_data*, basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:210
0x814f43 rewrite_blocks
../../gcc-trunk/gcc/tree-into-ssa.c:2216
0x81b64e update_ssa(unsigned int)
../../gcc-trunk/gcc/tree-into-ssa.c:3303
0xb9da0a tree_unswitch_single_loop
../../gcc-trunk/gcc/tree-ssa-loop-unswitch.c:358
0xb9dff8 tree_ssa_unswitch_loops()
../../gcc-trunk/gcc/tree-ssa-loop-unswitch.c:116
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$


-


int a, b, c, d, e;

void bar (int p)
{
  int f = b;
  e &= p <= (f ^= 0);
}

void foo ()
{
  for (; d; d++)
{
  bar (a && c);
  bar (0);
  bar (1);
}
}

[Bug rtl-optimization/58068] New: ICE in execute_strength_reduction at -O3 (both 32-bit and 64-bit modes)

2013-08-02 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58068

Bug ID: 58068
   Summary: ICE in execute_strength_reduction at -O3 (both 32-bit
and 64-bit modes)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux (both 32-bit and 64-bit modes). This is a regression from
4.8.x.

$ gcc-trunk -v
gcc version 4.9.0 20130801 (experimental) [trunk revision 201397] (GCC) 
$ gcc-trunk -O2 -c reduced.c
$ gcc-trunk -O3 -c reduced.c
reduced.c: In function ‘foo’:
reduced.c:4:6: internal compiler error: Segmentation fault
 void foo ()
  ^
0x7d52ef crash_signal
../../gcc-trunk/gcc/toplev.c:334
0x5d8ddb dominated_by_p(cdi_direction, basic_block_def const*, basic_block_def
const*)
../../gcc-trunk/gcc/dominance.c:974
0xb3f0c6 phi_add_costs
../../gcc-trunk/gcc/gimple-ssa-strength-reduction.c:2192
0xb4125d replace_uncond_cands_and_profitable_phis
../../gcc-trunk/gcc/gimple-ssa-strength-reduction.c:2242
0xb426d3 analyze_candidates_and_replace
../../gcc-trunk/gcc/gimple-ssa-strength-reduction.c:3371
0xb426d3 execute_strength_reduction
../../gcc-trunk/gcc/gimple-ssa-strength-reduction.c:3458
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ gcc-4.8 -O3 -c reduced.c
$ 



--


int a, c;
unsigned int b;

void foo ()
{
  for (; b < 2; b++)
if (++c * -1 > 0)
  for (;; a++)
;
}

[Bug tree-optimization/58069] New: ICE in tree_ssa_unswitch_loops at -O3 in 32 bit mode

2013-08-02 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58069

Bug ID: 58069
   Summary: ICE in tree_ssa_unswitch_loops at -O3 in 32 bit mode
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux in 32-bit mode only. This is a regression from 4.8.x.

It may be related to 58018, which also manifests in 64-bit mode though. 

This testcase is also a lot more complex than the one for 58018; I wasn't able
to reduce it further. 


$ gcc-trunk -v
gcc version 4.9.0 20130801 (experimental) [trunk revision 201397] (GCC) 
$ gcc-trunk -m64 -O3 reduced.c
/tmp/ccHrLaas.o: In function `main':
reduced.c:(.text.startup+0x7): undefined reference to `fn2'
reduced.c:(.text.startup+0x18): undefined reference to `fn3'
reduced.c:(.text.startup+0x54): undefined reference to `fn7'
reduced.c:(.text.startup+0x76): undefined reference to `fn4'
reduced.c:(.text.startup+0x87): undefined reference to `fn6'
reduced.c:(.text.startup+0x96): undefined reference to `fn5'
collect2: error: ld returned 1 exit status
$ gcc-trunk -m32 -O2 reduced.c
/tmp/cc6hsIbp.o: In function `main':
reduced.c:(.text.startup+0x55): undefined reference to `fn2'
reduced.c:(.text.startup+0x72): undefined reference to `fn4'
reduced.c:(.text.startup+0xfe): undefined reference to `fn7'
reduced.c:(.text.startup+0x117): undefined reference to `fn3'
reduced.c:(.text.startup+0x127): undefined reference to `fn6'
reduced.c:(.text.startup+0x137): undefined reference to `fn5'
collect2: error: ld returned 1 exit status
$ gcc-4.8 -m32 -O3 reduced.c
/tmp/ccCehBNw.o: In function `main':
reduced.c:(.text.startup+0xa): undefined reference to `fn2'
reduced.c:(.text.startup+0x18): undefined reference to `fn3'
reduced.c:(.text.startup+0x52): undefined reference to `fn7'
reduced.c:(.text.startup+0x6f): undefined reference to `fn4'
reduced.c:(.text.startup+0x7e): undefined reference to `fn6'
reduced.c:(.text.startup+0x8e): undefined reference to `fn5'
collect2: error: ld returned 1 exit status
$ gcc-trunk -m32 -O3 reduced.c
reduced.c: In function ‘main’:
reduced.c:43:5: internal compiler error: Segmentation fault
 int main ()
 ^
0x7d52ef crash_signal
../../gcc-trunk/gcc/toplev.c:334
0x7fd37b ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:314
0x7fd640 get_or_create_ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:362
0x8168ea get_reaching_def
../../gcc-trunk/gcc/tree-into-ssa.c:1184
0x81ca5a maybe_replace_use
../../gcc-trunk/gcc/tree-into-ssa.c:1784
0x81ca5a rewrite_update_stmt
../../gcc-trunk/gcc/tree-into-ssa.c:1967
0x81ca5a rewrite_update_enter_block
../../gcc-trunk/gcc/tree-into-ssa.c:2136
0xb3716a walk_dominator_tree(dom_walk_data*, basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:210
0x8155f3 rewrite_blocks
../../gcc-trunk/gcc/tree-into-ssa.c:2216
0x81bd0e update_ssa(unsigned int)
../../gcc-trunk/gcc/tree-into-ssa.c:3303
0xb9e4da tree_unswitch_single_loop
../../gcc-trunk/gcc/tree-ssa-loop-unswitch.c:358
0xb9eac8 tree_ssa_unswitch_loops()
../../gcc-trunk/gcc/tree-ssa-loop-unswitch.c:116
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 



---


int a, b, c, e, p;
static int *d = &c;

static int foo (int p)
{
  int f, i, j = 0, *g = &a; 
  int h[] = { 0, 0, 0, 1, 0, 0, 0, 0, 1 };
  for (i = 0; i < 1; i++)
{
  int *k = &b;
  {
int **l = 0;
int ***m = &l;
int n = &m;
j || fn2 ();
*n = 0;
if (*g)
  fn3 ();
else
  {
*k = 0;
fn4 ();
  }
  }
  *g = *k;

  for (j = 8; j >= 0; j--)
{
  for (f = 3; f <= 8; f++)
*d |= h[f] && *k;
  if (e)
{
  fn5 (fn6 () && 1);
  return 0;
}
  int *o = &h[7];
  *d = -1L <= ((*o ^= *k) && f);
}
  fn7 (p <= (a & 5UL));
}
}

int main ()
{
  p = foo (1);
  return 0;
}

[Bug tree-optimization/58131] New: ICE in execute, tree-vrp.c:9616 (in both 32-bit and 64-bit modes)

2013-08-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58131

Bug ID: 58131
   Summary: ICE in execute, tree-vrp.c:9616 (in both 32-bit and
64-bit modes)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux (both 32-bit and 64-bit modes). This is a regression from
4.8.x.

$ gcc-trunk -v
gcc version 4.9.0 20130811 (experimental) [trunk revision 201651] (GCC) 
$ gcc-trunk -O2 -c small.c  
$ gcc-4.8 -O3 -c small.c
$ gcc-trunk -O3 -c small.c
small.c: In function ‘foo’:
small.c:5:6: internal compiler error: Segmentation fault
 void foo ()
  ^
0x7e02bf crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x808dfb ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:314
0x8090c0 get_or_create_ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:362
0x822a1a get_reaching_def
../../gcc-trunk/gcc/tree-into-ssa.c:1184
0x8289ca maybe_replace_use
../../gcc-trunk/gcc/tree-into-ssa.c:1784
0x8289ca rewrite_update_stmt
../../gcc-trunk/gcc/tree-into-ssa.c:1967
0x8289ca rewrite_update_enter_block
../../gcc-trunk/gcc/tree-into-ssa.c:2136
0xb43e9a walk_dominator_tree(dom_walk_data*, basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:210
0x8216e3 rewrite_blocks
../../gcc-trunk/gcc/tree-into-ssa.c:2216
0x827c7e update_ssa(unsigned int)
../../gcc-trunk/gcc/tree-into-ssa.c:3319
0x940aa8 insert_range_assertions
../../gcc-trunk/gcc/tree-vrp.c:6102
0x940aa8 execute_vrp
../../gcc-trunk/gcc/tree-vrp.c:9515
0x940aa8 execute
../../gcc-trunk/gcc/tree-vrp.c:9616
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 






short a;
int b, c;
int d[1][4][2];

void foo ()
{
  int *e;
  for (b = 1;; b--)
{
  if (*e)
break;
  for (c = 2; c >= 0; c--)
{
  *e |= d[0][3][b] != a;
  int *f = &d[0][3][b];
  *f = 0;
}
}
}

[Bug middle-end/58143] New: wrong code at -O3 on x86_64-linux-gnu

2013-08-12 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143

Bug ID: 58143
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
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 and gcc 4.8 produce wrong code for the following testcase
on x86_64-linux when compiled at -O3 (in both 32-bit and 64-bit modes). This is
a regression from 4.7.x.


$ gcc-trunk -v
gcc version 4.9.0 20130812 (experimental) [trunk revision 201658] (GCC) 
$ gcc-trunk -O2 small.c
$ a.out
0
$ gcc-4.7 -O3 small.c
$ a.out
0
$ gcc-trunk -O3 small.c
$ a.out
-1
$ gcc-4.8 -O3 small.c
$ a.out
-1
$ 


--


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

int a, b, c, d, e, f, g, h = 1, i;

int foo (int p)
{
  return p < 0 && a < -2147483647 - 1 - p ? 0 : 1;
}

int *bar ()
{
  int j; 
  i = h ? 0 : 1 % h;
  for (j = 0; j < 1; j++)
for (d = 0; d; d++)
  for (e = 1; e;)
return 0;
  return 0;
}

int baz ()
{
  for (; b >= 0; b--)
for (c = 1; c >= 0; c--)
  {
int *k = &c;
for (;;)
  {
for (f = 0; f < 1; f++)
  {
g = foo (*k);
bar ();
  }
if (*k)
  break;
return 0;
  }
  }
  return 0;
}

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


[Bug middle-end/58143] wrong code at -O3 on x86_64-linux-gnu

2013-08-12 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143

--- Comment #2 from Zhendong Su  ---
Andrew, because of short-circuiting, when p >= 0, the expression "-2147483647 -
1 - p" isn't actually evaluated. 

Thanks for looking into this so quickly! 

Zhendong


[Bug tree-optimization/58223] New: wrong code at -O3 on x86_64-linux-gnu

2013-08-22 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58223

Bug ID: 58223
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
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 gcc 4.8) produces wrong code for the
following testcase on x86_64-linux when compiled at -O3 in both 32-bit and
64-bit modes. This is a regression from 4.7.x.

$ gcc-trunk -v
gcc version 4.9.0 20130822 (experimental) [trunk revision 201915] (GCC) 
$ gcc-4.7 -O3 reduced.c
$ a.out
1
$ gcc-trunk -O2 reduced.c
$ a.out
1
$ gcc-trunk -O3 reduced.c
$ a.out
0
$ gcc-4.8 -O3 reduced.c
$ a.out
0
$ 

---

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

int a[2], b;

int main ()
{
  for (b = 0; b < 2; b++)
{
  a[0] = 1;
  a[b] = 0;
}
  printf ("%d\n", a[0]);
  return 0;
}


[Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu

2013-08-23 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58227

Bug ID: 58227
   Summary: wrong code (hangs) at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
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 produces wrong code (that hangs) for the following
testcase on x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x.

It might be related to 58143, but 58143 also fails for 4.8. 


$ gcc-trunk -v
gcc version 4.9.0 20130822 (experimental) [trunk revision 201915] (GCC) 
$ gcc-4.8 -O3 reduced.c
$ a.out
$ gcc-trunk -O2 reduced.c
$ a.out
$ gcc-trunk -O3 reduced.c
$ a.out
^C
$ 


--

int a, b, d, e, f, *g, h, i;
volatile int c;

char foo (unsigned char p)
{
  return p + 1;
}

int bar () 
{
  for (h = 0; h < 3; h = foo (h))
{
  c;
  for (f = 0; f < 1; f++)
{
  i = a && 0 < -2147483647 - h ? 0 : 1;
  if (e)
for (; d;)
  b = 0;
  else
g = 0;
}
}
  return 0;
}

int main ()
{
  bar ();
  return 0;
}


[Bug tree-optimization/58227] wrong code (hangs) at -O3 on x86_64-linux-gnu

2013-08-23 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58227

--- Comment #2 from Zhendong Su  ---
But similar to 58143, because of short circuiting (since a == 0), the
expression "0 < -2147483647 - h ? 0 : 1" shouldn't be evaluated at all,
correct?  Or maybe I'm mistaken?  

Thanks for looking into this Marek!


[Bug tree-optimization/58228] New: wrong code (with vectorization?) at -O3 on x86_64-linux-gnu

2013-08-23 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58228

Bug ID: 58228
   Summary: wrong code (with vectorization?) at -O3 on
x86_64-linux-gnu
   Product: gcc
   Version: unknown
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 gcc 4.7 and 4.8, produces wrong code for the
following testcase on x86_64-linux when compiled at -O3 in both 32-bit and
64-bit modes. This is a regression from 4.6.x.

This seems to do with vectorization, as it goes away with -fno-tree-vectorize. 

$ gcc-trunk -v
gcc version 4.9.0 20130822 (experimental) [trunk revision 201915] (GCC) 
$ gcc-4.6 -O3 reduced.c
$ a.out
1
$ gcc-4.7 -O3 reduced.c
$ a.out
0
$ gcc-4.8 -O3 reduced.c
$ a.out
0
$ gcc-trunk -O3 reduced.c
$ a.out
0
$ gcc-trunk -O3 -fno-tree-vectorize reduced.c
$ a.out
1
$ 





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

int a[8][8] = {{1}};
int b, c, d, e;

int main ()
{
  for (c = 0; c < 8; c++)
for (b = 0; b < 2; b++)
  a[b + 4][c] = a[c][0];
  printf ("%d\n", a[4][4]);
  return 0;
}


[Bug tree-optimization/58246] New: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk)

2013-08-26 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58246

Bug ID: 58246
   Summary: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8,
and trunk)
   Product: gcc
   Version: unknown
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 gcc 4.6, 4.7, and 4.8) produces wrong code
for the following testcase on x86_64-linux when compiled at -O1 and above in
both 32-bit and 64-bit modes. 


$ gcc-trunk -v
gcc version 4.9.0 20130826 (experimental) [trunk revision 201986] (GCC) 
$ gcc-trunk -O0 small.c
$ a.out
1
$ gcc-trunk -O1 small.c
$ a.out
0
$ gcc-4.8 -O1 small.c
$ a.out
0
$ gcc-4.7 -O1 small.c
$ a.out
0
$ gcc-4.6 -O1 small.c
$ a.out
0
$ 




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

int a, b; 

int main ()
{
  int t[2] = {1,1};

  for (a = 0; a < 2; a++)
{
  b ^= t[a];
  t[a] = t[1] = 0;
}

  printf ("%d\n", b);

  return 0;
}


[Bug tree-optimization/58247] New: ICE in tree_unroll_loops_completely at -O3 (both 32-bit and 64-bit modes)

2013-08-26 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58247

Bug ID: 58247
   Summary: ICE in tree_unroll_loops_completely at -O3 (both
32-bit and 64-bit modes)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux in both 32-bit and 64-bit modes. This is a regression from
4.8.x.

It is likely a duplicate of 57592, although the stack traces are somewhat
different.


$ gcc-trunk -v
gcc version 4.9.0 20130826 (experimental) [trunk revision 201986] (GCC) 
$ gcc-trunk -O2 -c reduced.c
$ gcc-4.8 -O3 -c reduced.c
$ gcc-trunk -O3 -c reduced.c
reduced.c: In function ‘foo’:
reduced.c:14:6: internal compiler error: Segmentation fault
 void foo ()
  ^
0x7e6a0f crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x80f55b ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:314
0x80f820 get_or_create_ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:362
0x82924a get_reaching_def
../../gcc-trunk/gcc/tree-into-ssa.c:1184
0x82f1fa maybe_replace_use
../../gcc-trunk/gcc/tree-into-ssa.c:1784
0x82f1fa rewrite_update_stmt
../../gcc-trunk/gcc/tree-into-ssa.c:1967
0x82f1fa rewrite_update_enter_block
../../gcc-trunk/gcc/tree-into-ssa.c:2136
0xb4d77a walk_dominator_tree(dom_walk_data*, basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:210
0x827f13 rewrite_blocks
../../gcc-trunk/gcc/tree-into-ssa.c:2216
0x82e4ae update_ssa(unsigned int)
../../gcc-trunk/gcc/tree-into-ssa.c:3319
0x8963fc rewrite_into_loop_closed_ssa(bitmap_head_def*, unsigned int)
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:501
0xbb23fa tree_unroll_loops_completely(bool, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.c:1205
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


--

int a, b, c;
unsigned int d;

void baz(); 

void bar ()
{
  int e;
  for (d = 1; d < 2; d = d - 1)
for (e = 24; e; e = e - 3)
  a &= b >= e;
}

void foo ()
{
  for (;; b++)
for (c = 0; c < 1; c++)
  {
bar ();
baz ();
  }
}

[Bug tree-optimization/58248] New: wrong code at -O3 on x86_64-linux-gnu

2013-08-26 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

Bug ID: 58248
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
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 produces wrong code for the following testcase on
x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x.


$ gcc-trunk -v
gcc version 4.9.0 20130826 (experimental) [trunk revision 201986] (GCC) 
$ gcc-trunk -O2 reduced.c
$ a.out
1
$ gcc-4.8 -O3 reduced.c
$ a.out
1
$ gcc-trunk -O3 reduced.c
$ a.out
0
$ 


--


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

struct S
{
  int u;
}; 

int a = 1, b, c = 1, e, *f, *g;

static struct S d = {6};

void foo (int *p)
{
  c &= a != *p;
}

int main ()
{
  struct S h = d;
  int **i = &f;
  *i = g = &b;
  for (; h.u; h.u--)
{
  for (e = 0; e < 2; e++)
{
  foo (*i);
  *g = 0 > **i;
}
  *f = 0;
}
  printf ("%d\n", c);
  return 0;
}


[Bug tree-optimization/58248] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-08-27 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

--- Comment #2 from Zhendong Su  ---
Jakub, perhaps you used the testcase from 58247, not the one below?  

I double checked and still get wrong code on this one.


[Bug tree-optimization/58248] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-08-27 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

--- Comment #3 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #1)
> I get ICE instead, starting with r199048 .

This means that 58247 is probably indeed a dup of 57592, which also started
with r199048 (according to the comment on 57592).


[Bug tree-optimization/58248] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-08-27 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

--- Comment #5 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #4)
> No, the only change I've made to this testcase was instead of using
> printf use if (c != 1) __builtin_abort ();.

I checked the modified test case below: 

-

struct S
{
  int u;
}; 

int a = 1, b, c = 1, e, *f, *g;

static struct S d = {6};

void foo (int *p)
{
  c &= a != *p;
}

int main ()
{
  struct S h = d;
  int **i = &f;
  *i = g = &b;
  for (; h.u; h.u--)
{
  for (e = 0; e < 2; e++)
{
  foo (*i);
  *g = 0 > **i;
}
  *f = 0;
}

  if (c != 1)
__builtin_abort (); 

  return 0;
}

-

The log: 

$ gcc-trunk -O3 small.c
$ a.out
Aborted (core dumped)
$ gcc-trunk -O2 small.c
$ a.out
$ gcc-4.8 -O3 small.c
$ a.out
$ 

> If you can, next time please try to adjust the testcases such that they
> abort if miscompiled and exit with 0 exit status otherwise, gcc testsuite
> usually doesn't check for output from the testcases.

Got it; will do.


[Bug tree-optimization/58248] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-08-27 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

--- Comment #8 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #6)
> Are you sure your gcc isn't configured with --enable-checking=release ?

Jakub, below is my gcc configure: 

Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--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

Should I do "--enable-checking=release" instead of "--disable-checking"? 

> I really get:
> pr58248.c: In function ‘main’:
> pr58248.c:14:1: error: definition in block 2 follows the use
>  main ()
>  ^
> for SSA_NAME: _126 in statement:
> c.2_78 = _16 & _126;
> pr58248.c:14:1: internal compiler error: verify_ssa failed

[Bug tree-optimization/58248] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-08-27 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58248

--- Comment #10 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #9)
> For testing bugs against trunk it is better to omit both --disable-checking
> and --enable-checking=release and just use the default.
> Because otherwise the compiler doesn't perform various verifications and you
> could see a miscompilation which would otherwise be caught already at
> compile time.

Okay, thanks Jakub.


[Bug tree-optimization/58277] New: wrong code at -O3 (affecting 4.7, 4.8, and trunk)

2013-08-29 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58277

Bug ID: 58277
   Summary: wrong code at -O3 (affecting 4.7, 4.8, and trunk)
   Product: gcc
   Version: unknown
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 gcc 4.7 and 4.8) produces wrong code for the
attached testcase on x86_64-linux when compiled at -O3 in 32-bit mode. It is a
regression from 4.6.x.  

This one has been quite nasty to reduce; the attached testcase is the simplest
I was able to get. I believe it doesn't have any undefined behavior. 


$ 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
--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 20130829 (experimental) [trunk revision 202067] (GCC) 
$ gcc-trunk -m32 -O2 small.c
$ a.out
0
$ gcc-4.6 -m32 -O3 small.c
$ a.out
0
$ gcc-trunk -m32 -O3 small.c
$ a.out
0
Aborted (core dumped)
$ gcc-4.7 -m32 -O3 small.c
$ a.out
0
Aborted (core dumped)
$ gcc-4.8 -m32 -O3 small.c
$ a.out
0
Aborted (core dumped)
$


[Bug tree-optimization/58277] wrong code at -O3 (affecting 4.7, 4.8, and trunk)

2013-08-29 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58277

--- Comment #1 from Zhendong Su  ---
Created attachment 30725
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30725&action=edit
testcase


[Bug tree-optimization/58277] wrong code at -O3 (affecting 4.7, 4.8, and trunk)

2013-08-29 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58277

--- Comment #2 from Zhendong Su  ---
I'm also attaching a related testcase (small2.c) for both 32-bit and 64-bit
modes. 

$ gcc-trunk -m64 -O2 small2.c
$ a.out
$ gcc-4.6 -m64 -O3 small2.c
$ a.out
$ gcc-4.7 -m64 -O3 small2.c
$ a.out
Aborted (core dumped)
$ gcc-4.8 -m64 -O3 small2.c
$ a.out
Aborted (core dumped)
$ gcc-trunk -m64 -O3 small2.c
$ a.out
Aborted (core dumped)
$


[Bug tree-optimization/58277] wrong code at -O3 (affecting 4.7, 4.8, and trunk)

2013-08-29 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58277

--- Comment #3 from Zhendong Su  ---
Created attachment 30726
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30726&action=edit
another testcase for both 32-bit and 64-bit modes


[Bug tree-optimization/58277] [4.7 Regression] wrong code at -O3

2013-08-30 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58277

--- Comment #11 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #10)
> Fixed for 4.8+ so far, thanks for reporting it.

Thanks Jakub. Wow, that's quick! You folks are wonderful.


[Bug tree-optimization/58318] New: very slow compilation on x86_64-linux with -O3 and -g

2013-09-04 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58318

Bug ID: 58318
   Summary: very slow compilation on x86_64-linux with -O3 and -g
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code takes much longer to compile with both -O3 and -g on using
the current gcc trunk on x86_64-linux (in both 32-bit and 64-bit modes). 

4.8 is considerably faster than the trunk, while 4.6 and 4.7 are much slower. 

For reference, I also included the times for clang and icc. 


$ 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
--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 20130904 (experimental) [trunk revision 202240] (GCC) 
$
$
$ time gcc-trunk -O3 reduced.c
0.06user 0.00system 0:00.23elapsed 30%CPU (0avgtext+0avgdata 51792maxresident)k
0inputs+32outputs (0major+7258minor)pagefaults 0swaps
$
$
$ time gcc-trunk -O3 -g reduced.c
11.70user 0.68system 0:18.93elapsed 65%CPU (0avgtext+0avgdata
1133520maxresident)k
0inputs+64outputs (0major+297028minor)pagefaults 0swaps
$
$
$ time gcc-4.8 -O3 -g reduced.c
0.89user 0.12system 0:01.54elapsed 65%CPU (0avgtext+0avgdata
487552maxresident)k
0inputs+64outputs (0major+50913minor)pagefaults 0swaps
$
$
$ time gcc-4.7 -O3 -g reduced.c
84.09user 0.10system 1:57.58elapsed 71%CPU (0avgtext+0avgdata
580944maxresident)k
0inputs+64outputs (0major+41887minor)pagefaults 0swaps
$
$
$ time gcc-4.6 -O3 -g reduced.c
83.83user 0.16system 2:00.92elapsed 69%CPU (0avgtext+0avgdata
558864maxresident)k
0inputs+64outputs (0major+40733minor)pagefaults 0swaps
$
$
$ time clang-trunk -O3 -g reduced.c
0.02user 0.00system 0:00.09elapsed 34%CPU (0avgtext+0avgdata 52064maxresident)k
0inputs+40outputs (0major+6282minor)pagefaults 0swaps
$
$
$ time icc -O3 -g reduced.c
0.26user 2.39system 0:04.07elapsed 65%CPU (0avgtext+0avgdata 84000maxresident)k
1424inputs+184outputs (14major+16463minor)pagefaults 0swaps
$ 
$


-


int a, b, c, d;

int *foo (int *r, short s, short t)
{
  return &c;
}

short bar (int p)
{
  int t = 0;

  for (a = 0; a < 8; a++)
for (b = 0; b < 8; b++)
  for (p = 0; p < 8; p++)
for (d = 0; d < 8; d++)
  foo (&t, p, d);

  bar (0);

  return 0;
}

int main ()
{
  return 0;
}


[Bug tree-optimization/58326] [4.9 Regression] ICE in check_loop_closed_ssa_use, at tree-ssa-loop-manip.c:551

2013-09-05 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58326

--- Comment #2 from Zhendong Su  ---
For additional info, please find below a variant that fails only at -O3: 

-

int a, b, c, d;

void foo ()
{
  int e;

 lbl:
  for (c = 0; c < 2; c++)
{
  e = d;
  for (; a; a++)
{
  d = e;
  if (b)
goto lbl; 
}
}
}


[Bug tree-optimization/58318] very slow compilation on x86_64-linux with -O3 and -g and checking enabled

2013-09-05 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58318

--- Comment #2 from Zhendong Su  ---
> did you compare trunk with --enable-checking=release?  

Richard, you are right. Below is my 4.8 config: 

$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--with-gmp=/usr/local/gcc-4.8 --with-mpfr=/usr/local/gcc-4.8
--with-mpc=/usr/local/gcc-4.8 --with-cloog=/usr/local/gcc-4.8
--prefix=/usr/local/gcc-4.8
Thread model: posix
gcc version 4.8.1 (GCC) 
$


[Bug tree-optimization/58326] New: ICE in check_loop_closed_ssa_use, at tree-ssa-loop-manip.c:551

2013-09-05 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58326

Bug ID: 58326
   Summary: ICE in check_loop_closed_ssa_use, at
tree-ssa-loop-manip.c:551
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O2 and -O3 on x86_64-linux (both 32-bit and 64-bit modes). 

This is a regression from 4.8.x.


$ 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
--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 20130905 (experimental) [trunk revision 202269] (GCC) 
$ gcc-trunk -O1 -c small.c
$ gcc-4.8 -O2 -c small.c  
$ gcc-trunk -O2 -c small.c
small.c: In function ‘foo’:
small.c:5:6: internal compiler error: in check_loop_closed_ssa_use, at
tree-ssa-loop-manip.c:551
 void foo ()
  ^
0xa25746 check_loop_closed_ssa_use
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:550
0xa2717c check_loop_closed_ssa_stmt
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:566
0xa2717c verify_loop_closed_ssa(bool)
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:600
0xdc61d8 tree_unroll_loops_completely(bool, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.c:1239
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


-


int a, *d; 
long b;
short c;

void foo ()
{
  int e;
 lbl:
  for (c = 0; c < 2; c++)
{
  if (1 >> b)
break;
  e = *d;
  for (; a; a++)
{
  *d = e;
  if (b)
goto lbl;
}
}
}

[Bug tree-optimization/58342] New: ICE in propagate_threaded_block_debug_into, at tree-ssa-threadedge.c:623

2013-09-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58342

Bug ID: 58342
   Summary: ICE in propagate_threaded_block_debug_into, at
tree-ssa-threadedge.c:623
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O2 and -O3 with -g on x86_64-linux (both 32-bit and 64-bit modes). 

This is a regression from 4.8.x. 

This may be the same as 58340, but I couldn't reproduce the ICE using the
testcase for 58340 (see below for pt.ii). 


$ 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
--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 20130906 (experimental) [trunk revision 202308] (GCC) 
$
$ gcc-trunk -m32 -O2 -c small.c
$ gcc-trunk -O2 -c small.c
$ gcc-4.8 -O2 -g -c small.c  
$ gcc-trunk -O2 -g -c small.c
small.c: In function ‘main’:
small.c:8:5: internal compiler error: in propagate_threaded_block_debug_into,
at tree-ssa-threadedge.c:623
 int main ()
 ^
0xa93f53 propagate_threaded_block_debug_into(basic_block_def*,
basic_block_def*)
../../gcc-trunk/gcc/tree-ssa-threadedge.c:623
0xa94ca2 thread_across_edge(gimple_statement_d*, edge_def*, bool,
vec*, tree_node* (*)(gimple_statement_d*,
gimple_statement_d*))
../../gcc-trunk/gcc/tree-ssa-threadedge.c:1019
0x9fcc34 dom_opt_leave_block
../../gcc-trunk/gcc/tree-ssa-dom.c:1898
0xd46ebf walk_dominator_tree(dom_walk_data*, basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:241
0x9faa02 tree_ssa_dominator_optimize
../../gcc-trunk/gcc/tree-ssa-dom.c:827
0x9faa02 execute
../../gcc-trunk/gcc/tree-ssa-dom.c:951
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$
$
$ gcc-trunk -O2 -g -c pt.ii
$



-


int a, b, c, d;

int foo (int x, int y)
{
  return y == 0 ? x : 1 % y;
}

int main ()
{
  c = 0 || a;

  for (;;)
b = foo (d, c) && 1;

  return 0;
}

[Bug bootstrap/58340] [4.9 regression] gcc/cp/pt.c:7064:1: internal compiler error: in propagate_threaded_block_debug_into, at tree-ssa-threadedge.c:623

2013-09-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58340

--- Comment #4 from Zhendong Su  ---
I wasn't able to reproduce the ICE using the given testcase (pt.ii) with trunk
revision 202308, but I encountered an ICE (at -O2 and -O3 with -g) in the same
source location. It's reported as 58342 with the following small reduced test: 

--

int a, b, c, d;

int foo (int x, int y)
{
  return y == 0 ? x : 1 % y;
}

int main ()
{
  c = 0 || a;

  for (;;)
b = foo (d, c) && 1;

  return 0;
}


[Bug tree-optimization/58343] New: ICE in dfs_enumerate_from, at cfganal.c:1036

2013-09-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58343

Bug ID: 58343
   Summary: ICE in dfs_enumerate_from, at cfganal.c:1036
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O1 and above on x86_64-linux (both 32-bit and 64-bit modes). 

This is a regression from 4.8.x. 

$ 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
--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 20130906 (experimental) [trunk revision 202308] (GCC) 
$ gcc-trunk -O0 small.c
$ gcc-4.8 -O1 small.c
$ gcc-trunk -O1 small.c
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in dfs_enumerate_from, at cfganal.c:1036
 int main ()
 ^
0x608c4b dfs_enumerate_from(basic_block_def*, int, bool (*)(basic_block_def
const*, void const*), basic_block_def**, int, void const*)
../../gcc-trunk/gcc/cfganal.c:1036
0xa96d66 determine_bb_domination_status
../../gcc-trunk/gcc/tree-ssa-threadupdate.c:825
0xa96d66 thread_through_loop_header
../../gcc-trunk/gcc/tree-ssa-threadupdate.c:995
0xa96d66 thread_through_all_blocks(bool)
../../gcc-trunk/gcc/tree-ssa-threadupdate.c:1279
0x9fabab tree_ssa_dominator_optimize
../../gcc-trunk/gcc/tree-ssa-dom.c:849
0x9fabab execute
../../gcc-trunk/gcc/tree-ssa-dom.c:951
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


-

int a;

int main ()
{
  int b = a; 

  for (a = 1; a > 0; a--)
;

 lbl:
  if (b && a)
goto lbl; 

  return 0;
}

[Bug middle-end/58344] New: ICE with segfault at -O1 and above on x86_64-linux-gnu

2013-09-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58344

Bug ID: 58344
   Summary: ICE with segfault at -O1 and above 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 following code causes an ICE when compiled with the current gcc trunk at
-O1 and above on x86_64-linux (both 32-bit and 64-bit modes). 

This is a regression from 4.8.x. 


$ 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
--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 20130906 (experimental) [trunk revision 202308] (GCC) 
$ gcc-trunk -O0 -c small.c
$ gcc-4.8 -O1 -c small.c
$ gcc-trunk -O1 -c small.c
small.c: In function ‘foo’:
small.c:9:7: internal compiler error: Segmentation fault
   bar (a[0]);
   ^
0x924b2f crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x6daba0 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**)
../../gcc-trunk/gcc/expr.c:9758
0x5fc8ca expand_expr
../../gcc-trunk/gcc/expr.h:444
0x5fc8ca store_one_arg
../../gcc-trunk/gcc/calls.c:4502
0x6024f2 expand_call(tree_node*, rtx_def*, int)
../../gcc-trunk/gcc/calls.c:3042
0x6dbc2e expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**)
../../gcc-trunk/gcc/expr.c:10234
0x612b6f expand_call_stmt
../../gcc-trunk/gcc/cfgexpand.c:2180
0x612b6f expand_gimple_stmt_1
../../gcc-trunk/gcc/cfgexpand.c:2218
0x612b6f expand_gimple_stmt
../../gcc-trunk/gcc/cfgexpand.c:2370
0x6139b3 expand_gimple_basic_block
../../gcc-trunk/gcc/cfgexpand.c:4204
0x61557c gimple_expand_cfg
../../gcc-trunk/gcc/cfgexpand.c:4723
0x61557c execute
../../gcc-trunk/gcc/cfgexpand.c:4937
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


---


struct U {};

static struct U a[1];

extern void bar (struct U);

void foo ()
{
  bar (a[0]);
}

[Bug ipa/58345] New: ICE with SIGFPE at -O1 on x86_64-linux-gnu (affecting trunk and 4.8)

2013-09-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58345

Bug ID: 58345
   Summary: ICE with SIGFPE at -O1 on x86_64-linux-gnu (affecting
trunk and 4.8)
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ipa
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk and
4.8 at -O1 only on x86_64-linux (both 32-bit and 64-bit modes). 

This is a regression from 4.7.x. 

$ 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
--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 20130906 (experimental) [trunk revision 202308] (GCC) 
$ gcc-trunk -O0 -c small.c
$ gcc-trunk -O2 -c small.c
$ gcc-trunk -O3 -c small.c
$ gcc-trunk -Os -c small.c
$ gcc-4.7 -O1 -c small.c
$ gcc-trunk -O1 -c small.c
small.c: In function ‘foo’:
small.c:7:6: internal compiler error: Floating point exception
 void foo ()
  ^
0x924b2f crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x77ecd3 fold_array_ctor_reference
../../gcc-trunk/gcc/gimple-fold.c:2816
0x77ecd3 fold_ctor_reference
../../gcc-trunk/gcc/gimple-fold.c:2964
0x7827d2 fold_const_aggregate_ref_1(tree_node*, tree_node* (*)(tree_node*))
../../gcc-trunk/gcc/gimple-fold.c:3066
0x78443b fold_const_aggregate_ref
../../gcc-trunk/gcc/gimple-fold.c:3088
0x78443b maybe_fold_reference
../../gcc-trunk/gcc/gimple-fold.c:272
0x784df6 gimple_fold_call
../../gcc-trunk/gcc/gimple-fold.c:1091
0x784df6 fold_stmt_1
../../gcc-trunk/gcc/gimple-fold.c:1200
0x9763c9 fold_marked_statements
../../gcc-trunk/gcc/tree-inline.c:4380
0x980ff6 tree_function_versioning(tree_node*, tree_node*, vec*, bool, bitmap_head_def*, bool, bitmap_head_def*,
basic_block_def*)
../../gcc-trunk/gcc/tree-inline.c:5354
0xd85e62 save_inline_function_body
../../gcc-trunk/gcc/ipa-inline-transform.c:368
0xd85e62 inline_transform(cgraph_node*)
../../gcc-trunk/gcc/ipa-inline-transform.c:425
0x880e6f execute_one_ipa_transform_pass
../../gcc-trunk/gcc/passes.c:2039
0x880e6f execute_all_ipa_transforms()
../../gcc-trunk/gcc/passes.c:2079
0x636160 expand_function
../../gcc-trunk/gcc/cgraphunit.c:1702
0x63809d expand_all_functions
../../gcc-trunk/gcc/cgraphunit.c:1814
0x63809d compile()
../../gcc-trunk/gcc/cgraphunit.c:2151
0x638729 finalize_compilation_unit()
../../gcc-trunk/gcc/cgraphunit.c:2228
0x516813 c_write_global_declarations()
../../gcc-trunk/gcc/c/c-decl.c:10125
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ gcc-4.8 -O1 -c small.c
small.c: In function ‘foo’:
small.c:7:6: internal compiler error: Floating point exception
 void foo ()
  ^
0x7b925f crash_signal
../../gcc-4.8.1/gcc/toplev.c:332
0x678f55 fold_array_ctor_reference
../../gcc-4.8.1/gcc/gimple-fold.c:2819
0x678f55 fold_ctor_reference
../../gcc-4.8.1/gcc/gimple-fold.c:2967
0x67bd77 fold_const_aggregate_ref_1(tree_node*, tree_node* (*)(tree_node*))
../../gcc-4.8.1/gcc/gimple-fold.c:3069
0x67cd43 fold_const_aggregate_ref
../../gcc-4.8.1/gcc/gimple-fold.c:3091
0x67cd43 maybe_fold_reference
../../gcc-4.8.1/gcc/gimple-fold.c:277
0x67d434 gimple_fold_call
../../gcc-4.8.1/gcc/gimple-fold.c:1096
0x67d434 fold_stmt_1
../../gcc-4.8.1/gcc/gimple-fold.c:1202
0x7ee097 fold_marked_statements
../../gcc-4.8.1/gcc/tree-inline.c:4237
0x7f42b6 tree_function_versioning(tree_node*, tree_node*, vec*, bool, bitmap_head_def*, bool, bitmap_head_def*,
basic_block_def*)
../../gcc-4.8.1/gcc/tree-inline.c:5299
0xb3d7c2 save_inline_function_body
../../gcc-4.8.1/gcc/ipa-inline-transform.c:351
0xb3d7c2 inline_transform(cgraph_node*)
../../gcc-4.8.1/gcc/ipa-inline-transform.c:408
0x7319c7 execute_one_ipa_transform_pass
../../gcc-4.8.1/gcc/passes.c:2172
0x7319c7 execute_all_ipa_transforms()
../../gcc-4.8.1/gcc/passes.c:2208
0x59f876 expand_function
../../gcc-4.8.1/gcc/cgraphunit.c:1633
0x5a0d06 expand_all_functions
../../gcc-4.8.1/gcc/cgraphunit.c:1744
0x5a0d06 compile()
../../gcc-4.8.1/gcc/cgraphunit.c:2042
0x5a10b9 finalize_compilation_unit()
../../gcc-4.8.1/gcc/cgraphunit.c:2119
0x4e0453 c_write_global_declarations()
../../gcc-4.8.1/gcc/c/c-decl.c:10118
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gc

[Bug ipa/58346] New: ICE with SIGFPE at -O1 and above on x86_64-linux-gnu (affecting trunk, 4.8, 4.7, and 4.6)

2013-09-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58346

Bug ID: 58346
   Summary: ICE with SIGFPE at -O1 and above on x86_64-linux-gnu
(affecting trunk, 4.8, 4.7, and 4.6)
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ipa
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk, 4.8,
and 4.7 at -O1 and above (at only -O1 for 4.6) on x86_64-linux (both 32-bit and
64-bit modes). 

This should be related to 58345 (the backtraces are almost identical), but
affects also 4.6 and 4.7 as well as more optimization levels. 


$ 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
--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 20130906 (experimental) [trunk revision 202308] (GCC) 
$ gcc-trunk -O0 -c small.c
$ gcc-trunk -O1 -c small.c
small.c: In function ‘main’:
small.c:20:5: internal compiler error: Floating point exception
 int main ()
 ^
0x924b2f crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x77ecd3 fold_array_ctor_reference
../../gcc-trunk/gcc/gimple-fold.c:2816
0x77ecd3 fold_ctor_reference
../../gcc-trunk/gcc/gimple-fold.c:2964
0x7827d2 fold_const_aggregate_ref_1(tree_node*, tree_node* (*)(tree_node*))
../../gcc-trunk/gcc/gimple-fold.c:3066
0x78443b fold_const_aggregate_ref
../../gcc-trunk/gcc/gimple-fold.c:3088
0x78443b maybe_fold_reference
../../gcc-trunk/gcc/gimple-fold.c:272
0x784df6 gimple_fold_call
../../gcc-trunk/gcc/gimple-fold.c:1091
0x784df6 fold_stmt_1
../../gcc-trunk/gcc/gimple-fold.c:1200
0x9763c9 fold_marked_statements
../../gcc-trunk/gcc/tree-inline.c:4380
0x983404 optimize_inline_calls(tree_node*)
../../gcc-trunk/gcc/tree-inline.c:4475
0xd85fa3 inline_transform(cgraph_node*)
../../gcc-trunk/gcc/ipa-inline-transform.c:436
0x880e6f execute_one_ipa_transform_pass
../../gcc-trunk/gcc/passes.c:2039
0x880e6f execute_all_ipa_transforms()
../../gcc-trunk/gcc/passes.c:2079
0x636160 expand_function
../../gcc-trunk/gcc/cgraphunit.c:1702
0x63809d expand_all_functions
../../gcc-trunk/gcc/cgraphunit.c:1814
0x63809d compile()
../../gcc-trunk/gcc/cgraphunit.c:2151
0x638729 finalize_compilation_unit()
../../gcc-trunk/gcc/cgraphunit.c:2228
0x516813 c_write_global_declarations()
../../gcc-trunk/gcc/c/c-decl.c:10125
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


-


struct U {};
static struct U b[1] = { };

int a, **c, d, *e, f;

extern void bar (int, int, int, struct U); 
extern void foobar (int, int, int); 
extern int baz (int, int); 

static void foo ()
{
  bar (d, 0, 0, b[0]);
  foobar (0 >= f, 0, 0);
  **c = 0 == a;
  baz (**c, 0);
  baz (0, *e);
  *e = baz (0, 0);
}

int main ()
{
  foo ();
  return 0;
}

[Bug tree-optimization/58343] [4.9 Regression] ICE in dfs_enumerate_from, at cfganal.c:1036

2013-09-09 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58343

--- Comment #3 from Zhendong Su  ---
(In reply to Jeffrey A. Law from comment #2)

...  

> I've got a fix for this in testing.

Jeff, thanks very much for your explanation and quick fix.


[Bug middle-end/58387] New: wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58387

Bug ID: 58387
   Summary: wrong code at -Os and above on x86_64-linux-gnu (both
32-bit and 64-bit modes)
   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 produces wrong code for the attached testcase on
x86_64-linux-gnu when compiled at -Os and above in both 32-bit and 64-bit
modes. 

It is a regression from 4.8.x.  

$ 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
--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 20130910 (experimental) [trunk revision 202421] (GCC) 
$ gcc-trunk -O1 small.c
$ a.out
$ gcc-4.8 -O2 small.c
$ a.out
$ gcc-trunk -Os small.c
$ a.out
0
$ 


-

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

int a = -1; 

int main ()
{
  int b = a == 0 ? 0 : -a;
  if (b < 1)
printf ("%d\n", 0);
  return 0;
}


[Bug middle-end/58387] wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58387

--- Comment #2 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #1)
> Can't reproduce this, neither with 64-bit nor 32-bit.

Jakub, perhaps fixed in later revisions?  I tested it using 202421.


[Bug middle-end/58387] wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58387

--- Comment #4 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #3)
> Not even with r202421.
> Content of main with that revision for x86_64 -Os is:
>   .cfi_startproc
>   pushq   %rcx
>   .cfi_def_cfa_offset 16
>   movla(%rip), %esi
>   testl   %esi, %esi
>   je  .L4
>   negl%esi
>   testl   %esi, %esi
>   jg  .L3
>   jmp .L2
> .L4:
>   xorl%esi, %esi
> .L2:
>   movl$.LC0, %edi
>   xorl%eax, %eax
>   callprintf
> .L3:
>   xorl%eax, %eax
>   popq%rdx
>   .cfi_def_cfa_offset 8
>   ret


Here is what I have for x86_64 -Os: 

.cfi_startproc
pushq%rax
.cfi_def_cfa_offset 16
xorl%esi, %esi
movl$.LC0, %edi
xorl%eax, %eax
callprintf
xorl%eax, %eax
popq%rdx
.cfi_def_cfa_offset 8
ret
.cfi_endproc


Below is what I have for x86_64 -O1: 

.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movla(%rip), %eax
testl%eax, %eax
je.L2
negl%eax
testl%eax, %eax
jg.L3
.L2:
movl$0, %esi
movl$.LC0, %edi
movl$0, %eax
callprintf
.L3:
movl$0, %eax
addq$8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc

[Bug middle-end/58387] wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58387

--- Comment #6 from Zhendong Su  ---
(In reply to Richard Biener from comment #5)
> Cannot reproduce either.
> 
> Maybe you got hit by Jeffs bus introducing random bits into your bootstrap?
> 
> So I wonder if it reproduces for you if you rebuild GCC ;)

Hi guys, I rebuilt GCC, but it still reproduces for me (see below).  

Did you configure with --enable-checking=release? 


$ 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
--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 20130911 (experimental) [trunk revision 202489] (GCC) 
$ gcc-trunk -Os small.c
$ a.out
0
$ gcc-trunk -O1 small.c
$ a.out
$


[Bug middle-end/57393] [4.9 Regression] error: definition in block 4 follows the use / internal compiler error: verify_ssa failed

2013-09-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57393

--- Comment #36 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #35)
> The #c34 testcase seems to fail starting r199048 till current HEAD.

Besides John's new testcase from #c34, I've also encountered quite a number of
different testcases causing this same ICE (either at -O2 or -O3, with and
without -g), but the proposed patch by Easwaran from #c30 appears to fix
everything so far (tested with revision 202121).


[Bug middle-end/58387] [4.9 Regression] wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-13 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58387

--- Comment #12 from Zhendong Su  ---
(In reply to Jeffrey A. Law from comment #11)
> I know what's happening here.  It's obscure and quite nasty.
> 
> We have a jump threading opportunity which requires threading through a
> joiner block.  The jump thread leaving one edge of the joiner eventually
> reaches the same block as the joiner's other outgoing edge.
> 
> This is all fine and good as the threading code knows the conditions under
> which it's still safe to thread that jump.  Specifically it has to look at
> the PHI arguments for the two key edges and verify for each PHI that the
> values associated with the two key edges are the same.  This condition is in
> place to make the SSA graph updates easier to deal with.
> 
> At the time we discover and register the jump thread the condition holds and
> we're good to go.  However a short time later we discover that we can
> propagate a constant to one of those PHI arguments and do so.  Now the
> condition we needed for updating the SSA graph was broken.  We update the
> SSA graph incorrectly.
> 
> I'm going to have to review the SSA graph updating code a bit tomorrow AM. 
> In the mean time I'm going to revert the patch.

Jeff, I have another related testcase that only fails for the 32-bit mode (also
at -Os and above). It is a lot more complex, and the root cause is likely the
same as this one. In case it may be of some use to you (at least for testing
your fix), I'm including it below. The body of the conditional, which is not
executed, has an UB (accessing an initialized value: m[0]), which may explain
the difference in -m32 and -m64. 

Also btw everyone, does this mean that the whole testcase has UB (thus invalid)
even if the body of the if isn't executed at runtime at all?  I'm a bit unclear
on this, so any clarifications would be much appreciated.  


--


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

int a = -1, b = 1, f, **e;
static int c;
int *volatile d;

static void
foo (int p)
{
  int g, h, *i, *j = 0, k = g = a == 0 ? 0 : -a;
  if (p >= g)
{
  int l, n = 0, s = 0, m[7], o[42];
  int ***p = 0, q = &p, *r = &l, *v = &h; 
  int **t[3] = { &i, &r, &j };
  int *u[3] = { &n, &k, &s };
  e = &v;
  i = &o[0];
  d && *q;
  f = m[0]; 
  b = 0;
}
}

int main ()
{
  int x = 0, *y[1] = {&x};
  foo (c);
  printf ("%d\n", b);
  return 0;
}


[Bug middle-end/58387] [4.9 Regression] wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-13 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58387

--- Comment #15 from Zhendong Su  ---
(In reply to Jeffrey A. Law from comment #14)
> It's the action of executing the code with undefined behaviour which is the
> trigger.  ie, if you don't execute the code, then it has no effect on the
> defined/undefined state of the program as a whole.
> 

Thanks Jeff; that's what I thought. 

I noticed a stackoverflow discussion on this very topic: 

http://stackoverflow.com/questions/7961067/how-undefined-is-undefined-behavior 

Perhaps you folks could help inject some clarity to that discussion. 

> It's interesting that you mention undefined behaviour -- the primary
> motivation behind the patch that's causing this problem is to better expose
> to the analysis and optimization phases of GCC that certain paths, if
> executed, result in undefined behaviour.
> 

I see. But would it be better to inform the programmers instead? 

Please see this recent interesting work to appear at the upcoming SOSP
conference: 

http://css.csail.mit.edu/stack/

"Optimization-unstable code (unstable code for short) is an emerging class of
software bugs: code that is unexpectedly eliminated by compiler optimizations
due to undefined behavior in the program. Unstable code is present in many
systems, including the Linux kernel and the Postgres database server. The
consequences of unstable code range from incorrect functionality to missing
security checks.

STACK is a static checker that detects unstable code in C/C++ programs.
Applying STACK to widely used systems has uncovered 150+ new bugs that have
been confirmed and fixed by developers."

> In particular, propagating NULL pointers into PHI nodes in non-dominated
> successors exposes more opportunities to identify paths which, if executed,
> would dereference a NULL pointer.  We want to then isolate those paths which
> exhibit undefined behaviour from the rest of the code.  That allows the
> "real" code paths to be better optimized and the undefined behaviour paths
> to be pulled out of the main instruction stream.
> 
> The same can be done for out-of-bounds array accesses or uninitialized
> variables.


[Bug middle-end/58418] New: wrong code at -O2 and -O3 on x86_64-linux-gnu (in 32-bit mode)

2013-09-13 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58418

Bug ID: 58418
   Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu (in
32-bit mode)
   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 produces wrong code for the attached testcase on
x86_64-linux-gnu when compiled at -O2 and -O3 in 32-bit mode. 

It appears to be a regression from 4.8.x.  


$ 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
--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 20130913 (experimental) [trunk revision 202556] (GCC) 
$
$ gcc-trunk -m32 -O1 small.c
$ a.out
0
$ gcc-4.8 -m32 -O2 small.c  
$ a.out
0
$ gcc-trunk -m64 -O2 small.c
$ a.out
0
$ gcc-trunk -m32 -O2 small.c
$ a.out
1
$ 


--


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

int a, b, *c = &b, d = -1, e, f, *g, *h = &f, **i = &g, j;

unsigned int
foo (unsigned int p)
{
  return p == 0 ? 0 : 1 / p;
}

static int *
bar ()
{
  *c = *h = foo (d) & (-9 < d);
  for (e = 0; e; e++)
;
  return 0;
}

int
main ()
{
  for (; j; j++)
for (;; a--)
  ;
  *i = bar ();
  printf ("%d\n", f);
  return 0;
}


[Bug middle-end/58419] New: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode

2013-09-13 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58419

Bug ID: 58419
   Summary: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode
   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 mis-compiles the following code on x86_64-linux at -O3 in
32-bit mode. 

This is a regression from 4.8.x. 


$ 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
--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 20130913 (experimental) [trunk revision 202556] (GCC) 
$ gcc-trunk -m32 -O2 small.c
$ a.out
0
$ gcc-4.8 -m32 -O3 small.c
$ a.out
0
$ gcc-trunk -m64 -O3 small.c
$ a.out
0
$ gcc-trunk -m32 -O3 small.c
$ a.out
Segmentation fault (core dumped)
$ 


---

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

int a, g, i, k, *p; 
char b, e;
short c, h;
static short *d = &c;

char
foo (int p1, int p2)
{
  return p1 - p2;
}

int
bar ()
{
  short *q = &c;
  *q = 1;
  *p = 0;
  return 0;
}

int
main ()
{
  for (b = -22; b >= -29; b--)
{
  short *l = &h;
  char *m = &e;
  *l = a;
  g = foo (*m = k && *d, 1 > i) || bar (); 
}
  printf("0\n");
  return 0;
}


[Bug middle-end/58419] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu in 32-bit mode

2013-09-13 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58419

--- Comment #2 from Zhendong Su  ---
(In reply to H.J. Lu from comment #1)
> It is caused by r202468.

So it may have been a dup of 58418?


[Bug tree-optimization/58431] New: wrong code at -O3 on x86_64-linux-gnu (in 32-bit mode)

2013-09-15 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58431

Bug ID: 58431
   Summary: wrong code at -O3 on x86_64-linux-gnu (in 32-bit mode)
   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 mis-compiles the following code on x86_64-linux at -O3 in
32-bit mode. 

This is a regression from 4.8.x. 


$ 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
--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 20130915 (experimental) [trunk revision 202599] (GCC) 
$ gcc-trunk -m32 -O2 small.c
$ a.out
$ gcc-4.8 -m32 -O3 small.c
$ a.out
$ gcc-trunk -m32 -O3 small.c
$ a.out
Aborted (core dumped)
$ 


---


char a, h;
int b, d, e, g, j, k;
volatile int c;
short i;

int
main ()
{
  int m = i ^= 1;
  for (b = 0; b < 1; b++)
{
  char o = m;
  g = k;
  j = j || c;
  if (a != o)
for (; d < 1; d++)
  ;
  else
{
  char *p = &h;
  *p = 1;
  for (; e; e++)
;
}
}

  if (h != 0)
__builtin_abort(); 

  return 0;
}


[Bug tree-optimization/58451] New: ICE with segfault at -O3 on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-17 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58451

Bug ID: 58451
   Summary: ICE with segfault at -O3 on x86_64-linux-gnu (both
32-bit and 64-bit modes)
   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 following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x. 


$ 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
--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 20130917 (experimental) [trunk revision 202643] (GCC) 
$ gcc-trunk -O2 -c small.c
$ gcc-4.8 -O3 -c small.c
$ gcc-trunk -O3 -c small.c
small.c: In function ‘foo’:
small.c:3:6: internal compiler error: Segmentation fault
 void foo ()
  ^
0x9249bf crash_signal
../../gcc-trunk/gcc/toplev.c:335
0xa2719d find_uses_to_rename_use
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:369
0xa273d6 find_uses_to_rename_bb
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:427
0xa27b6d find_uses_to_rename
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:451
0xa27b6d rewrite_into_loop_closed_ssa(bitmap_head_def*, unsigned int)
../../gcc-trunk/gcc/tree-ssa-loop-manip.c:513
0x995070 tree_loop_distribution
../../gcc-trunk/gcc/tree-loop-distribution.c:1738
0x995070 execute
../../gcc-trunk/gcc/tree-loop-distribution.c:1781
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 



---


int *a[2], b, c, d, e;

void foo ()
{
  for (b = 1; b >= 0; b--)
if (e)
  {
a[b] = 0;
c = d = 0;
  }
}

[Bug tree-optimization/58451] ICE with segfault at -O3 on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-18 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58451

--- Comment #2 from Zhendong Su  ---
(In reply to Marek Polacek from comment #1)
> Should be already fixed by richi's r202644.

Verified (for 202680). Thanks.


[Bug middle-end/58479] New: slow compilation on x86_64-linux at -O1 (and above) with -g, but checking disabled

2013-09-19 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58479

Bug ID: 58479
   Summary: slow compilation on x86_64-linux at -O1 (and above)
with -g, but checking disabled
   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 following code takes much longer to compile at -O1 (and above) with -g
using the current gcc trunk on x86_64-linux (in both 32-bit and 64-bit modes). 

It also affects 4.6, 4.7, and 4.8 (with checking disabled), but to a lesser
extent (4 seconds vs. 12 seconds at -O1 with -g). 

This seems to be related to 58318, but 58318 manifests only when checking is
enabled. 

This may also be related to 58478. 


$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/su/software/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 --enable-checking=release
--with-gmp=/home/su/software/local/gcc-trunk
--with-mpfr=/home/su/software/local/gcc-trunk
--with-mpc=/home/su/software/local/gcc-trunk
--with-cloog=/home/su/software/local/gcc-trunk
--prefix=/home/su/software/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20130917 (experimental) (GCC) 
$
$ time gcc -O0 -g small.c
0.02user 0.00system 0:00.13elapsed 27%CPU (0avgtext+0avgdata 37888maxresident)k
0inputs+56outputs (0major+6439minor)pagefaults 0swaps
$ time gcc -O1 small.c
0.02user 0.02system 0:00.14elapsed 30%CPU (0avgtext+0avgdata 40144maxresident)k
0inputs+32outputs (0major+6560minor)pagefaults 0swaps
$ time gcc -O1 -g small.c
7.69user 0.53system 0:12.20elapsed 67%CPU (0avgtext+0avgdata
2632224maxresident)k
0inputs+32outputs (0major+180567minor)pagefaults 0swaps
$


-


int a, b, c, d, e, f; 

int main ()
{
  for (a = 0; a < 8; a++)
for (b = 0; b < 8; b++)
  for (c = 0; c < 8; c++)
for (d = 0; d < 8; d++)
  for (e = 0; e < 8; e++)
{
  int t[3][2][9] = {
{{f, f, f, f, f, f, f, f, f},
 {f, f, f, f, f, f, f, f, f}},
{{f, f, f, f, f, f, f, f, f},
 {f, f, f, f, f, f, f, f, f}},
{{f, f, f, f, f, f, f, f, f},
 {f, f, f, f, f, f, f, f, f}},
  };
}

  return 0;
}


[Bug middle-end/58478] very slow compilation at -O1 and above on a nested loop

2013-09-19 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58478

--- Comment #2 from Zhendong Su  ---
(In reply to Marek Polacek from comment #1)
> Confirmed.

That's quick; thanks Marek! 

Please also take a look at 58479 when you get a chance. 

It's related (as well as 58318).


[Bug tree-optimization/58318] very slow compilation on x86_64-linux with -O3 and -g and checking enabled

2013-09-19 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58318

--- Comment #3 from Zhendong Su  ---
> A quick check with a non-bootstrapped cc1 but release checking makes the
> slowdown go away.

Richard, there is related testcase that I have just reported (58479). It
manifests also under release checking. Thanks.


[Bug middle-end/58478] New: very slow compilation at -O1 and above on a nested loop

2013-09-19 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58478

Bug ID: 58478
   Summary: very slow compilation at -O1 and above on a nested
loop
   Product: gcc
   Version: 4.7.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following testcase takes much longer to compile at -O1 and above using GCC
4.7.3 on x86_64-linux (in both 32-bit and 64-bit modes). 

It does not seem to affect 4.8 and the current trunk. 


$ gcc-4.7 -v
Using built-in specs.
COLLECT_GCC=gcc-4.7
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.7/libexec/gcc/x86_64-unknown-linux-gnu/4.7.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.7.3/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--with-gmp=/usr/local/gcc-4.7 --with-mpfr=/usr/local/gcc-4.7
--with-mpc=/usr/local/gcc-4.7 --with-ppl=/usr/local/gcc-4.7
--with-cloog=/usr/local/gcc-4.7 --prefix=/usr/local/gcc-4.7
Thread model: posix
gcc version 4.7.3 (GCC) 
$ time gcc-4.7 -O0 small.c
0.02user 0.02system 0:00.05elapsed 86%CPU (0avgtext+0avgdata 38336maxresident)k
0inputs+32outputs (0major+6471minor)pagefaults 0swaps
$ time gcc-4.7 -O1 small.c
33.43user 0.12system 0:33.64elapsed 99%CPU (0avgtext+0avgdata
660976maxresident)k
0inputs+32outputs (0major+53023minor)pagefaults 0swaps
$ time gcc-4.8 -O1 small.c
0.02user 0.02system 0:00.05elapsed 85%CPU (0avgtext+0avgdata 36704maxresident)k
0inputs+32outputs (0major+6364minor)pagefaults 0swaps
$ time gcc-trunk -O1 small.c
0.04user 0.01system 0:00.07elapsed 82%CPU (0avgtext+0avgdata 42656maxresident)k
0inputs+32outputs (0major+6700minor)pagefaults 0swaps
$ 


-


int a, b, c, d, e; 

int main ()
{
  for (a = 0; a < 10; a++)
for (b = 0; b < 10; b++)
  for (c = 0; c < 10; c++)
for (d = 0; d < 10; d++)
  for (e = 0; e < 10; e++)
;
  return 0;
}


[Bug tree-optimization/58522] New: ICE with segfault at -O3 on x86_64-linux-gnu

2013-09-24 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58522

Bug ID: 58522
   Summary: ICE with segfault at -O3 on x86_64-linux-gnu
   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 following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x. 


$ 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 --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 20130924 (experimental) [trunk revision 202859] (GCC) 
$ 
$ gcc-trunk -O2 small.c   
$ gcc-4.8 -O3 small.c  
$ gcc-trunk -O3 small.c
small.c: In function ‘main’:
small.c:13:1: internal compiler error: Segmentation fault
 main ()
 ^
0x8108ef crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x83b957 ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:310
0x83bcc0 get_or_create_ssa_default_def(function*, tree_node*)
../../gcc-trunk/gcc/tree-dfa.c:362
0x8569ec get_reaching_def
../../gcc-trunk/gcc/tree-into-ssa.c:1184
0x85ca82 maybe_replace_use
../../gcc-trunk/gcc/tree-into-ssa.c:1791
0x85ca82 rewrite_update_stmt
../../gcc-trunk/gcc/tree-into-ssa.c:1974
0x85ca82 rewrite_update_dom_walker::before_dom_children(basic_block_def*)
../../gcc-trunk/gcc/tree-into-ssa.c:2150
0xb99ed7 dom_walker::walk(basic_block_def*)
../../gcc-trunk/gcc/domwalk.c:176
0x85560c rewrite_blocks
../../gcc-trunk/gcc/tree-into-ssa.c:2209
0x85bce6 update_ssa(unsigned int)
../../gcc-trunk/gcc/tree-into-ssa.c:3294
0x9826bd insert_range_assertions
../../gcc-trunk/gcc/tree-vrp.c:6103
0x9826bd execute_vrp
../../gcc-trunk/gcc/tree-vrp.c:9572
0x9826bd execute
../../gcc-trunk/gcc/tree-vrp.c:9673
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 



---


static int a, b;
char *c;
short *d, e;
int f;

short
foo (int p1, int p2)
{
  return p2 >= 0 || p1 > 1 >> p2 ? p1 : p1 << p2;
}

int
main ()
{
  int *g = &f, h;

  for (b = 4; b; b--)
{
  for (a = 0; a < 5; a++)
{
  e = foo (h != 0, *d);
  *g |= e;
  *d = 0;
}
  *c = 0;
}

  return 0;
}

[Bug tree-optimization/58522] [4.9 Regression] ICE with segfault at -O3 on x86_64-linux-gnu

2013-09-24 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58522

--- Comment #2 from Zhendong Su  ---
(In reply to Jakub Jelinek from comment #1)
> Started with r199048, so sounds like one of the many dups of the reassoc
> scheduling bugs.

Jakub, I think you are right. I somehow forgot to check it against the proposed
patch for 57393, which makes this ICE disappear.


[Bug middle-end/57393] [4.9 Regression] error: definition in block 4 follows the use / internal compiler error: verify_ssa failed

2013-09-24 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57393

--- Comment #39 from Zhendong Su  ---
*** Bug 58522 has been marked as a duplicate of this bug. ***


[Bug tree-optimization/58522] [4.9 Regression] ICE with segfault at -O3 on x86_64-linux-gnu

2013-09-24 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58522

Zhendong Su  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #3 from Zhendong Su  ---
Dup.

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


[Bug tree-optimization/58539] New: ICE with segfault at -O3 with -g enabled on x86_64-linux-gnu (affecting trunk, 4.8, and 4.7)

2013-09-25 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58539

Bug ID: 58539
   Summary: ICE with segfault at -O3 with -g enabled on
x86_64-linux-gnu (affecting trunk, 4.8, and 4.7)
   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 following code causes an ICE when compiled with the current gcc trunk, 4.8,
and 4.7 at -O3 with -g enabled on x86_64-linux in both 32-bit and 64-bit modes. 

This is a regression from 4.6.x. 

$ 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 --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 20130925 (experimental) [trunk revision 202882] (GCC) 
$
$ 
$ gcc-trunk -O3 -c small.c
$ gcc-4.6 -O3 -g -c small.c
$
$ 
$ gcc-trunk -O3 -g -c small.c
small.c: In function ‘bar’:
small.c:10:6: internal compiler error: Segmentation fault
 void bar ()
  ^
0x8109ef crash_signal
../../gcc-trunk/gcc/toplev.c:335
0x4ced0d get_use_from_ptr
../../gcc-trunk/gcc/tree-flow-inline.h:370
0x4ced0d link_use_stmts_after
../../gcc-trunk/gcc/tree-flow-inline.h:982
0x4ced0d first_imm_use_stmt
../../gcc-trunk/gcc/tree-flow-inline.h:1034
0x95c6a0 vect_create_epilog_for_reduction
../../gcc-trunk/gcc/tree-vect-loop.c:4566
0x95c6a0 vectorizable_reduction(gimple_statement_d*, gimple_stmt_iterator_d*,
gimple_statement_d**, _slp_tree*)
../../gcc-trunk/gcc/tree-vect-loop.c:5281
0x94f584 vect_transform_stmt(gimple_statement_d*, gimple_stmt_iterator_d*,
bool*, _slp_tree*, _slp_instance*)
../../gcc-trunk/gcc/tree-vect-stmts.c:5988
0x953b00 vect_transform_loop(_loop_vec_info*)
../../gcc-trunk/gcc/tree-vect-loop.c:5859
0x96c457 vectorize_loops()
../../gcc-trunk/gcc/tree-vectorizer.c:367
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$
$
$ gcc-4.8 -O3 -g -c small.c
small.c: In function ‘bar’:
small.c:10:6: internal compiler error: Segmentation fault
 void bar ()
  ^
0x7b925f crash_signal
../../gcc-4.8.1/gcc/toplev.c:332
0x8e1687 get_use_from_ptr
../../gcc-4.8.1/gcc/tree-flow-inline.h:370
0x8e1687 link_use_stmts_after
../../gcc-4.8.1/gcc/tree-flow-inline.h:982
0x8e1687 first_imm_use_stmt
../../gcc-4.8.1/gcc/tree-flow-inline.h:1034
0x8ecc18 vect_create_epilog_for_reduction
../../gcc-4.8.1/gcc/tree-vect-loop.c:4481
0x8ecc18 vectorizable_reduction(gimple_statement_d*, gimple_stmt_iterator*,
gimple_statement_d**, _slp_tree*)
../../gcc-4.8.1/gcc/tree-vect-loop.c:5196
0x8e1154 vect_transform_stmt(gimple_statement_d*, gimple_stmt_iterator*, bool*,
_slp_tree*, _slp_instance*)
../../gcc-4.8.1/gcc/tree-vect-stmts.c:5808
0x8e380f vect_transform_loop(_loop_vec_info*)
../../gcc-4.8.1/gcc/tree-vect-loop.c:5723
0x8faaea vectorize_loops()
../../gcc-4.8.1/gcc/tree-vectorizer.c:123
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$
$ 
$ gcc-4.7 -O3 -g -c small.c
small.c: In function ‘bar’:
small.c:10:6: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
$  





int a, b;

extern void baz (int);

int foo (int p)
{
  return p ? p : 1;
}

void bar ()
{
  int *c = &a, *d = &a;
  for (b = 0; b < 12; b++)
*d |= 1;
  foo (*c);
  baz (*c && 1);
}

[Bug tree-optimization/58570] New: wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-09-28 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58570

Bug ID: 58570
   Summary: wrong code at -Os and above on x86_64-linux-gnu (both
32-bit and 64-bit modes)
   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 mis-compiles the following code on x86_64-linux at -Os
and above in both 32-bit and 64-bit modes.

This is a regression from 4.8.x.

$ 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 20130928 (experimental) [trunk revision 203003] (GCC) 
$ 
$ gcc-trunk -O1 small.c
$ a.out
1
$ gcc-4.8 -O3 small.c
$ a.out
1
$ gcc-trunk -O3 small.c
$ a.out
0
$ gcc-trunk -O2 small.c
$ a.out
0
$ gcc-trunk -Os small.c
$ a.out
0
$






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

#pragma pack(1)
struct S
{
  int f0:15;
  int f1:29;
};

int a, b, c, e = 1, g;
static struct S d[6];
long long f;

static short
foo (int p)
{
  for (b = 0; b < 1; b++)
{
  g |= 1;
  for (; a < 1; a++)
{
  int i;
  if (p < c - 1)
return 4;
  if (p)
for (i = 0; i < 6; i++)
  {
struct S j = {1, 1};
d[i] = j;
  }
  continue;
}
}
  return 0;
}

int
main ()
{
  if (e)
foo (!f);
  printf ("%d\n", d[0].f1);
  return 0;
}


[Bug tree-optimization/58640] New: wrong code (segfaults) at -O3 on x86_64-linux-gnu

2013-10-05 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58640

Bug ID: 58640
   Summary: wrong code (segfaults) at -O3 on x86_64-linux-gnu
   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 mis-compiles the following code on x86_64-linux at -O3 in
both 32-bit and 64-bit modes, resulting in a segfault. 

This is a regression from 4.8.x. 


$ 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 20131005 (experimental) [trunk revision 203223] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
$ gcc-4.8 -O3 small.c; a.out
$ gcc-trunk -O3 small.c; a.out
Segmentation fault (core dumped)
$ 


-


int a, b, c, d = 1, e;

static signed char
foo ()
{
  int f, g = a;

  for (f = 1; f < 3; f++)
for (; b < 1; b++)
  {
if (d)
  for (c = 0; c < 4; c++)
for (f = 0; f < 3; f++)
  {
for (e = 0; e < 1; e++)
  a = g;
if (f)
  break;
  }
else if (f)
  continue;
return 0;
  }
  return 0;
}

int
main ()
{
  foo ();
  return 0;
}


[Bug tree-optimization/58653] New: wrong code (segfaults) at -O3 on x86_64-linux-gnu in 64-bit mode (affecting gcc 4.6 to trunk)

2013-10-06 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58653

Bug ID: 58653
   Summary: wrong code (segfaults) at -O3 on x86_64-linux-gnu in
64-bit mode (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) mis-compiles the following
code on x86_64-linux at -O3 in 64-bit mode, resulting in a segfault. 


$ 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 20131006 (experimental) [trunk revision 203227] (GCC) 
$ 
$ gcc-trunk -m64 -O2 small.c; a.out
$ gcc-trunk -m32 -O3 small.c; a.out
$
$ gcc-trunk -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.8 -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.7 -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$ gcc-4.6 -m64 -O3 small.c; a.out
Segmentation fault (core dumped)
$  

-

int a, c, e[5][2]; 
unsigned int d;

int
main ()
{
  for (d = 0; d < 2; d++)
if (a ? 0 : e[c + 3][d] & e[c + 4][d])
  break;
  return 0;
}


[Bug tree-optimization/58662] New: wrong code at -O2 and -O3 on x86_64-linux-gnu (in 64-bit mode)

2013-10-07 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58662

Bug ID: 58662
   Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu (in
64-bit mode)
   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 miscompiles the attached testcase on x86_64-linux-gnu at
-O2 and -O3 in 64-bit mode. 

It is a regression from 4.8.x.  


$ 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 20131007 (experimental) [trunk revision 203235] (GCC) 
$ 
$ gcc-trunk -Os small.c; a.out
0
$ gcc-trunk -O2 small.c; a.out
-1008071096
$ gcc-trunk -O3 small.c; a.out
86090104
$
$ gcc-4.8 -O2 small.c; a.out
0
$ gcc-4.8 -O3 small.c; a.out
0 
$ 

-

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

int a, b, c, d;

int
foo (int p1, short p2)
{
  return p1 / p2;
}

int
main ()
{
  char e;
  d = foo (a == 0, (0, 35536)); 
  e = d % 14;
  b = e && c;
  printf ("%d\n", b);
  return 0;
}


[Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu

2013-10-09 Thread su at cs dot ucdavis.edu
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;
}


[Bug middle-end/58677] wrong code at -O1 on x86_64-linux-gnu

2013-10-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58677

--- Comment #3 from Zhendong Su  ---
(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.


[Bug tree-optimization/58685] New: wrong code at -Os on x86_64-linux-gnu in 64-bit mode (affecting gcc trunk, 4.8, and 4.7)

2013-10-10 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58685

Bug ID: 58685
   Summary: wrong code at -Os on x86_64-linux-gnu in 64-bit mode
(affecting gcc trunk, 4.8, and 4.7)
   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.7 and 4.8) miscompiles the following code
on x86_64-linux at -Os in 64-bit mode. 

This is a regression from 4.6.x. 


$ 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 20131010 (experimental) [trunk revision 203390] (GCC) 
$ 
$ gcc-trunk -m64 -O1 small.c; a.out
$ gcc-trunk -m64 -O2 small.c; a.out
$ gcc-trunk -m32 -Os small.c; a.out
$ gcc-4.6 -m64 -Os small.c; a.out
$ 
$ gcc-trunk -m64 -Os small.c; a.out
a.out: :1564818584: H?l$?L?d$?H?-? : Assertion `' failed.
Aborted (core dumped)
$ gcc-4.8 -m64 -Os small.c; a.out
a.out: :2138443464: H?l$?L?d$?H?-? : Assertion `' failed.
Aborted (core dumped)
$ gcc-4.7 -m64 -Os small.c; a.out
a.out: :1796453480: H?l$?L?d$?H?-? : Assertion `' failed.
Aborted (core dumped)
$


-

int a, b, c = 1, d, e;
int *f = &e, *g = &e, *i;

void __assert_fail (char *);

void
fn1 ()
{
  if (a)
i = 0;
}

int
fn2 ()
{
  0 ? (void) 0 : __assert_fail ("");
  for (; d;)
;
  return 0;
}

int
fn3 (int *p1)
{
  for (b = 0; b >= 0; b--)
{
  int *h = &e;
  *h = 0;
  if (*p1)
continue;
  e = 1;
}
  fn1 ();
  c ? (void) 0 : __assert_fail ("");
  return 0;
}

int
main ()
{
  fn3 (g);
  fn3 (g);
  if (*f);
  else
0 ? (void) 0 : __assert_fail ("");
  return 0;
}


[Bug tree-optimization/58696] New: wrong code at -O3 on x86_64-linux-gnu

2013-10-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58696

Bug ID: 58696
   Summary: wrong code at -O3 on x86_64-linux-gnu
   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 produces wrong code for the following testcase on
x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x.


$ 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 20131011 (experimental) [trunk revision 203458] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
0
$ gcc-4.8 -O3 small.c; a.out
0
$ gcc-trunk -O3 small.c; a.out
1
$ 


--


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

int a[20], b, c; 

int
fn1 ()
{
  int d, e, f, g = 0; 

  a[12] = 1;
  for (e = 0; e < 3; e++)
for (d = 0; d < 2; d++)
  {
for (f = 0; f < 2; f++)
  {
g ^= a[12] > 1;
if (g)
  return 0;
if (b)
  break;
  }
for (c = 0; c < 1; c++)
  a[d] = a[e * 3 + 9]; 
  }
  return 0;
}

int
main ()
{
  fn1 ();
  printf ("%d\n", a[0]);
  return 0;
}


[Bug tree-optimization/58640] [4.9 Regression] wrong code (segfaults) at -O3 on x86_64-linux-gnu

2013-10-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58640

--- Comment #8 from Zhendong Su  ---
(In reply to Jeffrey A. Law from comment #7)
> Fixed on trunk.

Verified (also against the original). 

Thanks Jeff.


[Bug tree-optimization/58697] New: wrong code (segfaults) at -O3

2013-10-11 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58697

Bug ID: 58697
   Summary: wrong code (segfaults) at -O3
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

GCC 4.8.1 miscompiles the following code on x86_64-linux at -O3 in 64-bit mode,
resulting in a segfault. 

It doesn't seem to affect the current trunk and 4.7.x. 

It is related to 58653. 


$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--with-gmp=/usr/local/gcc-4.8 --with-mpfr=/usr/local/gcc-4.8
--with-mpc=/usr/local/gcc-4.8 --with-cloog=/usr/local/gcc-4.8
--prefix=/usr/local/gcc-4.8
Thread model: posix
gcc version 4.8.1 (GCC) 
$ 
$
$ gcc-4.8 -O3 small.c; a.out
Segmentation fault (core dumped)
$
$ gcc-trunk -O3 small.c; a.out
$
$ gcc-4.7 -O3 small.c; a.out
$ 


--

int b, f, d[5][2];
unsigned int c;

int
main ()
{
  for (c = 0; c < 2; c++)
if (d[b + 3][c] & d[b + 4][c])
  if (f)
break;
  return 0;
}


[Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)

2013-10-14 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58726

Bug ID: 58726
   Summary: wrong code at -Os on x86_64-linux-gnu (affecting
trunk/4.7/4.6, but not 4.8)
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following code on x86_64-linux at -Os in
both 32-bit and 64-bit modes. 

This is a regression from 4.8.x. 

It also affects 4.6.x and 4.7.x. 

$ 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 20131014 (experimental) [trunk revision 203511] (GCC) 
$ 
$ gcc-trunk -O1 small.c; a.out
-9162
$ gcc-trunk -Os small.c; a.out
-32768
$ 
$ gcc-4.8 -Os small.c; a.out
-9162
$ 
$ gcc-4.7 -Os small.c; a.out
-32768
$ gcc-4.6 -Os small.c; a.out
-32768
$ 




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

int a, c;

union
{
  int f1;
  int f2:1;
} b;

short
foo (short p)
{
  return p < 0 ? p : a;
}

int
main ()
{
  b.f1 = 56374;
  unsigned short d;
  int e = b.f2;
  d = e == 0 ? b.f1 : 0;
  c = foo (d);
  printf ("%d\n", c);
  return 0;
}


[Bug tree-optimization/58731] New: wrong code (hangs) at -O3 on x86_64-linux-gnu

2013-10-14 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58731

Bug ID: 58731
   Summary: wrong code (hangs) at -O3 on x86_64-linux-gnu
   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 and gcc 4.8 produce wrong code that hangs for the
following testcase on x86_64-linux when compiled at -O3 (in both 32-bit and
64-bit modes). 

This is a regression from 4.7.x.

The testcase also triggers a different issue at -O2: a spurious "undefined
behavior" warning (see below). 

$ 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 20131014 (experimental) [trunk revision 203572] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
small.c: In function ‘main’:
cc1: warning: iteration 5u invokes undefined behavior
[-Waggressive-loop-optimizations]
small.c:6:3: note: containing loop
   for (b = 4; b > -30; b--)
   ^
$ 
$ gcc-trunk -Os small.c; a.out
$
$ gcc-trunk -O3 small.c; a.out
^C
$ gcc-4.8 -O3 small.c; a.out
^C
$
$ gcc-4.7 -O3 small.c; a.out
$  


--


int a, b, c, d, e;

int
main ()
{
  for (b = 4; b > -30; b--)
for (; c;)
  for (;;)
{
  e = a > 2147483647 - b;
  if (d)
break;
}
  return 0;
}

[Bug tree-optimization/58732] New: wrong code at -O3 on x86_64-linux-gnu

2013-10-14 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58732

Bug ID: 58732
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The attached testcase is miscompiled by gcc 4.8.1 on x86_64-linux-gnu at -O3 in
both 32-bit and 64-bit modes. 

It does not seem to affect the current gcc trunk, 4.6.x, and 4.7.x.

$ gcc-4.8 -v  
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--with-gmp=/usr/local/gcc-4.8 --with-mpfr=/usr/local/gcc-4.8
--with-mpc=/usr/local/gcc-4.8 --with-cloog=/usr/local/gcc-4.8
--prefix=/usr/local/gcc-4.8
Thread model: posix
gcc version 4.8.1 (GCC) 
$ 
$ gcc-4.8 -O2 small.c; a.out
$
$ gcc-4.8 -O3 small.c; a.out
Aborted (core dumped)
$ 
$ gcc-trunk -O3 small.c; a.out
$ gcc-4.6 -O3 small.c; a.out 
$ gcc-4.7 -O3 small.c; a.out
$ 





static int a = -1, c, d;
int b[10];

int
main ()
{
  for (d = 1; d >= 0; d--)
{
  b[8] = 0;
  for (c = 0; c; c++)
;
  b[d+8] = a;
}

  if (b[8] != -1)
__builtin_abort(); 

  return 0;
}


[Bug tree-optimization/58732] wrong code at -O3 on x86_64-linux-gnu

2013-10-14 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58732

--- Comment #1 from Zhendong Su  ---
Below is a simpler testcase that should demonstrate the same issue: 

--

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

int a, b[2];

int
main ()
{
  for (a = 1; a >= 0; a--)
{
  b[1] = 1;
  b[a] = 0;
}

  if (b[1] != 1)
__builtin_abort(); 

  return 0;
}


[Bug tree-optimization/58830] New: wrong code at -O3 on x86_64-linux-gnu (affecting 4.8.x, but not trunk or 4.7.x)

2013-10-21 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58830

Bug ID: 58830
   Summary: wrong code at -O3 on x86_64-linux-gnu (affecting
4.8.x, but not trunk or 4.7.x)
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following testcase is miscompiled by 4.8.2 (as well 4.8.0 and 4.8.1) on
x86_64-linux at -O3 in both 32-bit and 64-bit modes. 

It works with the current gcc trunk, 4.7.x and 4.6.x. 

$ gcc-4.8.2 -v   
Using built-in specs.
COLLECT_GCC=gcc-4.8.2
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.2/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-checking=release
--with-gmp=/home/su/software/local/gcc-4.8.2
--with-mpfr=/home/su/software/local/gcc-4.8.2
--with-mpc=/home/su/software/local/gcc-4.8.2
--with-cloog=/home/su/software/local/gcc-4.8.2
--prefix=/home/su/software/local/gcc-4.8.2
Thread model: posix
gcc version 4.8.2 (GCC) 
$ 
$ gcc-4.8.2 -O2 small.c; a.out
0
$ gcc-4.7.3 -O3 small.c; a.out
0
$ gcc-4.6.4 -O3 small.c; a.out
0
$ gcc-trunk -O3 small.c; a.out
0
$ 
$ gcc-4.8.2 -O3 small.c; a.out
2
$ gcc-4.8.1 -O3 small.c; a.out
2
$ gcc-4.8.0 -O3 small.c; a.out
2
$ 


-


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

int b, c, d, f, g, h, i, j[6], *l = &b, *m, n, *o, r; 
char k;

static int
foo ()
{
  char *p = &k;

  for (; d; d++)
if (i)
  h = 0;
else
  h = c || (r = 0);

  for (f = 0; f < 2; f++)
{
  unsigned int q;
  *l = 0;
  if (n)
*m = g;
  if (g)
o = 0;
  for (q = -8; q >= 5; q++)
(*p)--;
}

  return 0;
}

int
main ()
{
  foo ();
  printf("%d\n",
j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[0]
^ (k & 15)]);
  return 0;
}


[Bug tree-optimization/58831] New: wrong code at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode

2013-10-21 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58831

Bug ID: 58831
   Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu in
64-bit mode
   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 and 4.8.x miscompiles the following code on x86_64-linux
at -O2 and -O3 in 64-bit mode. 

This is a regression from 4.7.x. 

I had hoped to reduce it even further, but it's the best I have 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 20131021 (experimental) [trunk revision 203907] (GCC) 
$ 
$ gcc-trunk -m64 -O1 small.c; a.out
$ gcc-trunk -m32 -O2 small.c; a.out
$ gcc-4.7.3 -m64 -O2 small.c; a.out
$ 
$ gcc-trunk -m64 -O2 small.c; a.out
a.out: small.c:14: fn1: Assertion `r' failed.
Aborted (core dumped)
$ gcc-trunk -m64 -O3 small.c; a.out
a.out: small.c:14: fn1: Assertion `r' failed.
Aborted (core dumped)
$ 
$ gcc-4.8.2 -m64 -O2 small.c; a.out
a.out: small.c:14: fn1: Assertion `r' failed.
Aborted (core dumped)
$ gcc-4.8.2 -m64 -O3 small.c; a.out
a.out: small.c:14: fn1: Assertion `r' failed.
Aborted (core dumped)
$ 





#include

int a, *b, c, d, f, **i, p, q, *r;
short o, j;

static int
fn1 (int *p1, int **p2)
{
  int **e = &b;
  for (; p; p++)
*p1 = 1;
  *e = *p2 = &d;

  assert(r); 

  return c;
}

static int **
fn2 ()
{
  for (f = 0; f != 42; f++)
{
  int *g[3] = {0, 0, 0};
  for (o = 0; o; o--)
for (; a > 1;)
  {
int **h[1] = { &g[2] };
  }
}
  return &r;
}



static short
fn3 ()
{
  for (; q < 1;)
return 0;
  fn2 ();
  fn1 (0, 0);
  return 0;
}

int
main ()
{
  i = fn2 ();
  j = fn1 (b, i);
  fn3 ();
  return 0;
}


[Bug tree-optimization/58832] New: wrong code at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode

2013-10-21 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58832

Bug ID: 58832
   Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu in
64-bit mode
   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 miscompiles the following code on x86_64-linux at -O2 and
-O3 in 64-bit mode. 

This is a regression from 4.8.x and may be related to 58831, which also affects
gcc 4.8.x though. 

$ 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 20131021 (experimental) [trunk revision 203907] (GCC) 
$ 
$ gcc-trunk -m64 -O1 small.c; a.out
$ gcc-trunk -m32 -O2 small.c; a.out
$ gcc-4.8.2 -m64 -O2 small.c; a.out
$ gcc-4.7.3 -m64 -O2 small.c; a.out
$ 
$ gcc-trunk -m64 -O2 small.c; a.out
a.out: small.c:9: fn1: Assertion `d || (1 & e)' failed.
Aborted (core dumped)
$ gcc-trunk -m64 -O3 small.c; a.out
a.out: small.c:9: fn1: Assertion `d || (1 & e)' failed.
Aborted (core dumped)
$ 
$ 


-


#include

int a, b, c, *d, e, g;

void
fn1 (int *p1, int **p2)
{
  *p2 = &g;
  assert (d || (1 & e));
}

static int **
fn2 ()
{
  int *f = &b;
  for (; c; c--)
f = 0;
  assert(a || f);
  return 0;
}

static unsigned short
fn3 ()
{
  fn2 ();
  fn1 (0, &d);
  return 0;
}


int
main ()
{
  fn2 ();
  fn3 ();
  return 0;
}


[Bug target/58865] New: wrong code at -Os on x86_64-linux-gnu

2013-10-24 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58865

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

The current gcc trunk miscompiles the following code on x86_64-linux at -Os in
64-bit mode. 

This is a regression from 4.8.x. 

Perhaps related to 58685 (which also affects 4.7.x and 4.8.x though)? 

$ 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 20131024 (experimental) [trunk revision 204004] (GCC) 
$ 
$ gcc-trunk -m64 -O1 small.c; a.out
$ gcc-trunk -m64 -O2 small.c; a.out
$ gcc-trunk -m32 -Os small.c; a.out
$ gcc-4.8.2 -m64 -Os small.c; a.out
$ 
$ gcc-trunk -m64 -Os small.c; a.out
a.out: :1534914408: H?l$?L?d$?H?-? : Assertion `(null)' failed.
Aborted (core dumped)
$ 


-


int *c, **d = &c, e, f;

void __assert_fail (int *, char *);

void
fn1 ()
{
  fn1 ();
  c ? (void) 0 : __assert_fail (0, "");
}

void
fn2 (int p1, int **p2)
{
  *p2 = &f;
  c ? (void) 0 : __assert_fail (0, "");
  for (e = 1; e < 1; e--)
if (p1)
  break;
}

int
main ()
{
  fn2 (0, d);
  return 0;
}


[Bug rtl-optimization/58831] [4.7/4.8/4.9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode

2013-10-28 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58831

--- Comment #16 from Zhendong Su  ---
(In reply to Eric Botcazou from comment #15)
> Fixed everywhere (and twice to be really sure :-)

Verified (also against the original tests). Thanks.


[Bug tree-optimization/58921] New: ICE with segfault on valid code at -O3 on x86_64-linux-gnu

2013-10-29 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58921

Bug ID: 58921
   Summary: ICE with segfault on valid code at -O3 on
x86_64-linux-gnu
   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 following code causes an ICE when compiled with the current gcc trunk at
-O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It is a regression from 4.8.x. 

$ 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=none --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 20131029 (experimental) [trunk revision 204186] (GCC) 
$ 
$ gcc-trunk -O2 small.c
$ gcc-4.8 -O3 small.c
$ 
$ gcc-trunk -O3 small.c
small.c: In function ‘fn1’:
small.c:5:1: internal compiler error: Segmentation fault
 fn1 ()
 ^
0x81d4af crash_signal
../../gcc-trunk/gcc/toplev.c:334
0x967417 gimple_code
../../gcc-trunk/gcc/gimple.h:1222
0x967417 vect_get_vec_def_for_operand(tree_node*, gimple_statement_d*,
tree_node**)
../../gcc-trunk/gcc/tree-vect-stmts.c:1438
0x9678e8 vect_get_vec_defs(tree_node*, tree_node*, gimple_statement_d*,
vec*, vec*,
_slp_tree*, int)
../../gcc-trunk/gcc/tree-vect-stmts.c:1627
0x96c267 vectorizable_operation
../../gcc-trunk/gcc/tree-vect-stmts.c:3779
0x972b64 vect_transform_stmt(gimple_statement_d*, gimple_stmt_iterator_d*,
bool*, _slp_tree*, _slp_instance*)
../../gcc-trunk/gcc/tree-vect-stmts.c:5951
0x97711b vect_transform_loop(_loop_vec_info*)
../../gcc-trunk/gcc/tree-vect-loop.c:5880
0x98f4d6 vectorize_loops()
../../gcc-trunk/gcc/tree-vectorizer.c:373
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 
$ 


-


int a[7];
int b;

void
fn1 ()
{
  for (; b; b++)
a[b] = ((a[b] <= 0) == (a[0] != 0));
}

int
main ()
{
  return 0;
}

[Bug tree-optimization/58955] New: wrong code at -O3 on x86_64-linux-gnu

2013-10-31 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58955

Bug ID: 58955
   Summary: wrong code at -O3 on x86_64-linux-gnu
   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 miscompiles the following testcase on x86_64-linux-gnu at
-O3 (in both 32-bit and 64-bit modes). 

This is a regression from 4.8.x.

$ 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=none --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 20131031 (experimental) [trunk revision 204248] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
1
$ gcc-4.8 -O3 small.c; a.out
1 
$ gcc-trunk -O3 small.c; a.out
0
$ 




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

int a, b, c, d[4] = { 0, 0, 0, 1 };

int
main ()
{
  for (; a < 4; a++)
{
  int e = d[a];
  for (c = 1; c < 1; c++);
  b = e;
  d[a] = 0;
}
  printf ("%d\n", b);
  return 0;
}


[Bug tree-optimization/58956] New: wrong code at -O1 and above (affecting gcc 4.6 to trunk)

2013-10-31 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58956

Bug ID: 58956
   Summary: wrong code at -O1 and above (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 gcc 4.6.x, 4.7.x, and 4.8.x) produces wrong
code for the following testcase on x86_64-linux-gnu when compiled at -O1 and
above in 64-bit mode. 

$ 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=none --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 20131031 (experimental) [trunk revision 204248] (GCC) 
$ 
$ gcc-trunk -O0 small.c; a.out
1
$ gcc-trunk -O1 small.c; a.out
0
$ gcc-4.8 -O1 small.c; a.out
0
$ gcc-4.7 -O1 small.c; a.out
0
$ gcc-4.6 -O1 small.c; a.out
0
$ 
$ clang-trunk -O1 small.c; a.out
1
$ icc -O1 small.c; a.out
1
$ 


---


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

struct S
{
  int f0;
} a = {1}, b, g, *c = &b, **f = &c;

int *d, **e = &d, h;

void __assert_fail ();

struct S
foo ()
{
  *e = &h;
  if (!d) 
__assert_fail ();
  *f = &g;
  return a;
}

int
main ()
{
  struct S *i = c;
  *i = foo ();
  printf ("%d\n", b.f0);
  return 0;
}


[Bug tree-optimization/58957] New: compilation hangs at -O3 on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-10-31 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58957

Bug ID: 58957
   Summary: compilation hangs at -O3 on x86_64-linux-gnu (both
32-bit and 64-bit modes)
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes gcc 4.8.2 (as well as gcc 4.8.0 and gcc 4.8.1) to
hang at -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It doesn't affect gcc trunk, 4.7.x, and 4.6.x. 


$ gcc-trunk -O3 small.c  
$ gcc-4.6 -O3 small.c
$ gcc-4.7 -O3 small.c
$ 
$ gcc-4.8 -O3 small.c
^C
$
$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.2/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-checking=release
--with-gmp=/home/su/software/local/gcc-4.8.2
--with-mpfr=/home/su/software/local/gcc-4.8.2
--with-mpc=/home/su/software/local/gcc-4.8.2
--with-cloog=/home/su/software/local/gcc-4.8.2
--prefix=/home/su/software/local/gcc-4.8.2
Thread model: posix
gcc version 4.8.2 (GCC) 
$ 


--


void __assert_fail () __attribute__ ((__noreturn__));

int a[10], b, c, d, *e, **f = &e, g, i, *j; 
unsigned int h;

int *
foo ()
{
  for (c = 0; c < 10; c++)
for (i = 1; i >= 0; i--)
  for (d = 0; d < 10; d++)
{
  j = &a[d];
  j >= &a[0] && j <= &a[9] ? (void) 0 : __assert_fail ();
}
  return &b;
}

int
main ()
{
  for (g = 3; g < 10; g++)
for (; h < 10; h++)
  *f = foo ();
  return 0;
}


[Bug tree-optimization/58955] [4.9 Regression] wrong code at -O3 on x86_64-linux-gnu

2013-11-02 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58955

--- Comment #2 from Zhendong Su  ---
Here is another testcase that seems related (also goes away with
-fno-tree-loop-distribute-patterns.  




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

int a, b[10];

int
main ()
{
  for (; a < 2; a++)
{
  b[a] = 1;
  b[a + 1] = 0;
}
  printf ("%d\n", b[1]);
  return 0;
}


[Bug tree-optimization/58984] New: wrong code at -Os and above on x86_64-linux-gnu in 64-bit mode

2013-11-03 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58984

Bug ID: 58984
   Summary: wrong code at -Os and above on x86_64-linux-gnu in
64-bit mode
   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 and 4.8.x miscompile the following code on x86_64-linux
at -Os and above in 64-bit mode. 

This is a regression from 4.7.x. 

$ 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 20131103 (experimental) [trunk revision 204333] (GCC) 
$ 
$ gcc-trunk -O1 small.c; a.out
1
$ gcc-trunk -Os small.c; a.out
0
$ gcc-4.8.2 -Os small.c; a.out
0
$ gcc-4.7.3 -Os small.c; a.out
1
$ 



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

struct S
{
  int f0:8;
  int:6;
  int f1:5;
};

int a, *c = &a, e, n, b;

static int
foo (struct S p)
{
  const unsigned short *f[36];
  for (; e < 2; e++)
{
  const unsigned short **i = &f[0];
  *c ^= 1;
  if (p.f1)
{
  *i = 0;
  return b;
}
}
  return 0;
}

int
main ()
{
  struct S o = { 1, 1 };
  foo (o);
  n || o.f0;
  printf ("%d\n", a);
  return 0;
}


[Bug tree-optimization/58957] [4.8 Regression] compilation slow at -O3 on x86_64-linux-gnu (both 32-bit and 64-bit modes)

2013-11-04 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58957

--- Comment #3 from Zhendong Su  ---
(In reply to Richard Biener from comment #2)
> I think it's just awfully slow (deep loop nest, possible to unroll
> completely).
> It terminates for me on the branch and for 4.8.2 and 4.8.1.
> 
>  tree CFG cleanup:   8.49 (88%) usr   0.00 ( 0%) sys   8.52 (87%)
> wall 783 kB ( 2%) ggc
>  TOTAL :   9.70 0.06 9.80   
> 51528 kB
> 
> on trunk and 4.7.3:
> 
>  TOTAL :   0.09 0.00 0.10   
> 1865 kB

You are right Richard --- I didn't wait long enough.


[Bug rtl-optimization/58997] New: ICE on valid code at -O3 on x86_64-linux-gnu (affecting gcc trunk and 4.8.2)

2013-11-04 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58997

Bug ID: 58997
   Summary: ICE on valid code at -O3 on x86_64-linux-gnu
(affecting gcc trunk and 4.8.2)
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk and
4.8.2 at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes). 

It is a regression from 4.8.1. 

$ 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 20131105 (experimental) [trunk revision 204377] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
$ gcc-4.8.1 -O3 small.c; a.out
$ 
$ gcc-trunk -O3 small.c
small.c: In function ‘foo’:
small.c:18:1: internal compiler error: in simplify_subreg, at
simplify-rtx.c:5901
 }
 ^
0x82fdca simplify_subreg(machine_mode, rtx_def*, machine_mode, unsigned int)
../../gcc-trunk/gcc/simplify-rtx.c:5900
0x830169 simplify_gen_subreg(machine_mode, rtx_def*, machine_mode, unsigned
int)
../../gcc-trunk/gcc/simplify-rtx.c:6121
0x74a138 iv_subreg
../../gcc-trunk/gcc/loop-iv.c:439
0x74a138 iv_analyze_op
../../gcc-trunk/gcc/loop-iv.c:1164
0x74a257 iv_analyze_expr(rtx_def*, rtx_def*, machine_mode, rtx_iv*)
../../gcc-trunk/gcc/loop-iv.c:971
0x74a8c4 iv_analyze_def
../../gcc-trunk/gcc/loop-iv.c:1122
0x749fea iv_analyze_op
../../gcc-trunk/gcc/loop-iv.c:1193
0x7516ef may_unswitch_on
../../gcc-trunk/gcc/loop-unswitch.c:201
0x7516ef unswitch_single_loop
../../gcc-trunk/gcc/loop-unswitch.c:324
0x751c9c unswitch_single_loop
../../gcc-trunk/gcc/loop-unswitch.c:379
0x751f30 unswitch_loops()
../../gcc-trunk/gcc/loop-unswitch.c:148
0x742cb7 rtl_unswitch
../../gcc-trunk/gcc/loop-init.c:537
0x742cb7 execute
../../gcc-trunk/gcc/loop-init.c:567
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 
$ gcc-4.8.2 -O3 small.c; a.out
small.c: In function ‘foo’:
small.c:18:1: internal compiler error: in simplify_subreg, at
simplify-rtx.c:5732
 }
 ^
0x7bf858 simplify_subreg(machine_mode, rtx_def*, machine_mode, unsigned int)
../../gcc-4.8.2/gcc/simplify-rtx.c:5731
0x7c5c18 simplify_gen_subreg(machine_mode, rtx_def*, machine_mode, unsigned
int)
../../gcc-4.8.2/gcc/simplify-rtx.c:5952
0x6f6438 iv_subreg
../../gcc-4.8.2/gcc/loop-iv.c:428
0x6f6438 iv_analyze_op
../../gcc-4.8.2/gcc/loop-iv.c:1154
0x6f5a2a iv_analyze_expr(rtx_def*, rtx_def*, machine_mode, rtx_iv*)
../../gcc-4.8.2/gcc/loop-iv.c:961
0x6f6094 iv_analyze_def
../../gcc-4.8.2/gcc/loop-iv.c:1112
0x6f62ea iv_analyze_op
../../gcc-4.8.2/gcc/loop-iv.c:1183
0x6fce35 may_unswitch_on
../../gcc-4.8.2/gcc/loop-unswitch.c:201
0x6fce35 unswitch_single_loop
../../gcc-4.8.2/gcc/loop-unswitch.c:324
0x6fd3f4 unswitch_single_loop
../../gcc-4.8.2/gcc/loop-unswitch.c:379
0x6fd628 unswitch_loops()
../../gcc-4.8.2/gcc/loop-unswitch.c:148
0x6f00a7 rtl_unswitch
../../gcc-4.8.2/gcc/loop-init.c:453
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 
$ 


---


int a, b, c, e;
short d;
char h;

int
foo ()
{
  for (; b;)
{
  d = a ? c : 1 % a;
  c = d;
  h = d;
  if (!h) 
for (; e;)
  ;
}
  return 0;
}

int
main ()
{
  foo ();
  return 0;
}

[Bug tree-optimization/59014] New: wrong code at -Os and above on x86_64-linux-gnu

2013-11-05 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59014

Bug ID: 59014
   Summary: wrong code at -Os and above on x86_64-linux-gnu
   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 miscompiles the following code on x86_64-linux-gnu at -Os
and above in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x.

$ 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 20131105 (experimental) [trunk revision 204388] (GCC) 
$ 
$ gcc-trunk -O1 small.c; a.out
2
$ gcc-4.8.2 -Os small.c; a.out
2
$ gcc-trunk -Os small.c; a.out
0
$ 
$ 


-


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

int a = 2, b, c, d;

int
foo ()
{
  for (;; c++)
if ((b > 0) | (a & 1))
  ;
else
  {
d = a;
return 0;
  }
}

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


[Bug tree-optimization/59045] New: wrong code at -O3 on x86_64-linux-gnu

2013-11-07 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59045

Bug ID: 59045
   Summary: wrong code at -O3 on x86_64-linux-gnu
   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 miscompiles the following testcase on x86_64-linux-gnu at
-O3 (in both 32-bit and 64-bit modes). 

This is a regression from 4.8.x.

$ 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 20131107 (experimental) [trunk revision 204540] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
1
$ gcc-4.8.2 -O3 small.c; a.out
1
$ gcc-trunk -O3 small.c; a.out
0
$ 


---


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

int a[7][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0,
0}, {1, 0, 0} };
int b, c, d;

int
main ()
{
  for (; b < 3; b++)
for (c = 1; c >= 0; c--)
  {
d = a[b + 4][c];
a[b + 4][c] = 0;
  }
  printf ("%d\n", d);
  return 0;
}


[Bug tree-optimization/59047] New: wrong code for bitfields at -O3 on x86_64-linux-gnu

2013-11-08 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59047

Bug ID: 59047
   Summary: wrong code for bitfields at -O3 on x86_64-linux-gnu
   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 miscompiles the following testcase on x86_64-linux-gnu at
-O3 (in both 32-bit and 64-bit modes). 

This is a regression from 4.8.x.

$ 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 204560] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
1
$ gcc-4.8.2 -O3 small.c; a.out
1
$ 
$ gcc-trunk -O3 small.c; a.out
0
$ 


--


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

struct
{
  int f0;
  int f1:1;
  int f2:2;
} a = {0, 0, 1};

int b, c, *d, e, f;

int
fn1 ()
{
  for (; b < 1; ++b)
{
  for (e = 0; e < 1; e = 1)
{
  int **g = &d;
  *g = &c;
} 
  *d = 0;
  f = a.f1;
  if (f)
return 0;
}
  return 0;
}

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


[Bug tree-optimization/59058] New: wrong code at -O3 on x86_64-linux-gnu (affecting gcc 4.6 to trunk)

2013-11-08 Thread su at cs dot ucdavis.edu
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;
}


[Bug tree-optimization/59062] New: poor code generated at -Os (affecting all gcc versions): 10+ sec vs. 1 sec at -O0

2013-11-09 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59062

Bug ID: 59062
   Summary: poor code generated at -Os (affecting all gcc
versions): 10+ sec vs. 1 sec at -O0
   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) produces poor code for the
 following testcase on x86_64-linux-gnu at -Os in both 32-bit and 64-bit modes. 

The produced code has the same or very similar size. 

$ 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 20131109 (experimental) [trunk revision 204611] (GCC) 
$ 
$ gcc-trunk -O0 small.c   
$ time a.out
1.02user 0.00system 0:01.05elapsed 97%CPU (0avgtext+0avgdata 1584maxresident)k
0inputs+0outputs (0major+142minor)pagefaults 0swaps
$ gcc-trunk -O1 small.c
$ time a.out
0.68user 0.00system 0:00.68elapsed 98%CPU (0avgtext+0avgdata 1568maxresident)k
0inputs+0outputs (0major+140minor)pagefaults 0swaps
$ gcc-trunk -Os small.c
$ time a.out
12.84user 0.00system 0:12.86elapsed 99%CPU (0avgtext+0avgdata 1568maxresident)k
0inputs+0outputs (0major+140minor)pagefaults 0swaps
$ 





#pragma pack(1)
struct 
{
  int f0:23;
  unsigned int f1:23;
  unsigned int f2:7;
} b, c; 

unsigned int a; 

int 
main ()
{
  for (; a != 14; a += 9)
c = b; 
  return 0;
}


[Bug tree-optimization/59102] New: ICE on valid code at -Os and above on x86_64-linux-gnu

2013-11-12 Thread su at cs dot ucdavis.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59102

Bug ID: 59102
   Summary: ICE on valid code at -Os and above on x86_64-linux-gnu
   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 following code causes an ICE when compiled with the current gcc trunk at
-Os and above on x86_64-linux-gnu (in both 32-bit and 64-bit modes). 

This is a regression from 4.8.x.

$ 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++,fortran,lto
--disable-werror --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 20131112 (experimental) [trunk revision 204721] (GCC) 
$ 
$ gcc-trunk -O1 small.c; a.out
$ gcc-4.8.2 -Os small.c; a.out
$
$ gcc-trunk -Os small.c
small.c: In function ‘main’:
small.c:16:1: internal compiler error: gimple check: expected
gimple_assign(error_mark), have gimple_call() in gimple_assign_lhs, at
gimple.h:1774
 main ()
 ^
0x7bafab gimple_check_failed
../../gcc-trunk/gcc/gimple.c:1139
0x51c805 gimple_assign_lhs
../../gcc-trunk/gcc/gimple.h:1774
0xe28b58 gimple_assign_lhs
../../gcc-trunk/gcc/gimple.h:1774
0xe28b58 insert_trap_and_remove_trailing_statements
../../gcc-trunk/gcc/gimple-ssa-isolate-paths.c:73
0xe29861 gimple_ssa_isolate_erroneous_paths
../../gcc-trunk/gcc/gimple-ssa-isolate-paths.c:300
0xe29861 execute
../../gcc-trunk/gcc/gimple-ssa-isolate-paths.c:365
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


-


int a, b, c, f;

struct S
{
  int f0;
} d, *e;

struct S
foo ()
{
  b = c = b || a == 0 || f % 11;
  return d;
}

int
main ()
{
  foo ();
  if (b);
  else
{
  struct S **g = &e;
  *g = 0;
  *e = foo ();
}
  return 0;
}

  1   2   3   4   5   6   7   8   >