[Bug tree-optimization/115933] New: wrong code at -O1 with "-fno-tree-loop-optimize -ftree-vrp -fno-tree-ch -fgcse" on x86_64-linux-gnu

2024-07-15 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115933

Bug ID: 115933
   Summary: wrong code at -O1 with "-fno-tree-loop-optimize
-ftree-vrp -fno-tree-ch -fgcse" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier.

Compiler Explorer: https://godbolt.org/z/5PoGKzzcx

[550] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240715 (experimental) (GCC) 
[551] % 
[551] % gcctk -O1 -fno-tree-loop-optimize -ftree-vrp -fno-tree-ch -fgcse
small.c
[552] % ./a.out
Aborted
[553] % 
[553] % cat small.c
int a, b;
unsigned c() {
  int d, e = d = 2;
  if (a < 0)
for (e = 0; e < 1; e++)
  d = 0;
  b = e;
  return d;
}
int main() {
  c();
  if (b != 2)
__builtin_abort();
  return 0;
}

[Bug rtl-optimization/115929] [15 regression] ICE on valid code at -O{2,3} with "-fschedule-insns" on x86_64-linux-gnu: Segmentation fault

2024-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115929

--- Comment #1 from Zhendong Su  ---
Another likely related test.

Compiler Explorer: https://godbolt.org/z/o7Wrd7P66

[551] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240714 (experimental) (GCC) 
[552] % 
[552] % gcctk -O2 -fno-gcse -fschedule-insns -fno-guess-branch-probability
-fno-tree-fre -fno-tree-ch small.c
during RTL pass: late_combine
small.c: In function ‘main’:
small.c:42:1: internal compiler error: in compare_nodes, at
splay-tree-utils.tcc:958
   42 | }
  | ^
0x24979f5 internal_error(char const*, ...)
../../gcc-trunk/gcc/diagnostic-global-context.cc:491
0xa462c6 fancy_abort(char const*, int, char const*)
../../gcc-trunk/gcc/diagnostic.cc:1725
0xa30b0f
rootless_splay_tree
>::compare_nodes(rtl_ssa::insn_info::order_node*,
rtl_ssa::insn_info::order_node*)
../../gcc-trunk/gcc/splay-tree-utils.tcc:958
0xa30b0f
rootless_splay_tree
>::compare_nodes(rtl_ssa::insn_info::order_node*,
rtl_ssa::insn_info::order_node*)
../../gcc-trunk/gcc/splay-tree-utils.tcc:944
0xa30b0f rtl_ssa::insn_info::slow_compare_with(rtl_ssa::insn_info const&) const
../../gcc-trunk/gcc/rtl-ssa/insns.cc:88
0x2389403 rtl_ssa::insn_info::compare_with(rtl_ssa::insn_info const*) const
../../gcc-trunk/gcc/rtl-ssa/member-fns.inl:550
0x2389403 operator()
../../gcc-trunk/gcc/rtl-ssa/accesses.cc:549
0x2389403 lookup >
../../gcc-trunk/gcc/splay-tree-utils.tcc:536
0x238ab8a
rtl_ssa::lookup_clobber(rooted_splay_tree
> >&, rtl_ssa::insn_info*)
../../gcc-trunk/gcc/rtl-ssa/accesses.cc:551
0x238ab8a rtl_ssa::function_info::add_clobber(rtl_ssa::clobber_info*,
rtl_ssa::clobber_group*)
../../gcc-trunk/gcc/rtl-ssa/accesses.cc:661
0x238e36c rtl_ssa::function_info::add_def(rtl_ssa::def_info*)
../../gcc-trunk/gcc/rtl-ssa/accesses.cc:950
0x239227a rtl_ssa::function_info::apply_changes_to_insn(rtl_ssa::insn_change&,
hash_set >&)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:688
0x2394de4
rtl_ssa::function_info::change_insns(array_slice)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:888
0x233966a run
../../gcc-trunk/gcc/late-combine.cc:452
0x233966a combine_into_uses
../../gcc-trunk/gcc/late-combine.cc:683
0x2339db7 execute
../../gcc-trunk/gcc/late-combine.cc:711
0x2339db7 execute
../../gcc-trunk/gcc/late-combine.cc:760
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[553] % 
[553] % cat small.c
int printf(const char *, ...);
int a[6], b, c;
char d, l;
struct {
  char e;
  int f;
  int : 8;
  long g;
  long h;
} i[1][9] = {0};
unsigned j;
void n(char p) { b = b >> 8 ^ a[b ^ p]; }
int main() {
  int k, o;
  while (b) {
k = 0;
for (; k < 9; k++) {
  b = b ^ a[l];
  n(j);
  if (o)
printf();
  long m = i[c][k].f;
  b = b >> 8 ^ a[l];
  n(m >> 32);
  n(m);
  if (o)
printf("%d", d);
  b = b >> 8 ^ l;
  n(2);
  n(0);
  if (o)
printf();
  b = b ^ a[l];
  n(i[c][k].g >> 2);
  n(i[c][k].g);
  if (o)
printf();
  printf("%d", i[c][k].f);
}
  }
  return 0;
}

[Bug rtl-optimization/115929] New: ICE on valid code at -O{2, 3} with "-fschedule-insns" on x86_64-linux-gnu: Segmentation fault

2024-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115929

Bug ID: 115929
   Summary: ICE on valid code at -O{2,3} with "-fschedule-insns"
on x86_64-linux-gnu: Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier. 

Compiler Explorer: https://godbolt.org/z/eaE7z3ser

[536] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240714 (experimental) (GCC) 
[537] % 
[537] % gcctk -O2 -fschedule-insns small.c
during RTL pass: late_combine
small.c: In function ‘main’:
small.c:20:1: internal compiler error: Segmentation fault
   20 | }
  | ^
0x24979f5 internal_error(char const*, ...)
../../gcc-trunk/gcc/diagnostic-global-context.cc:491
0x1190963 crash_signal
../../gcc-trunk/gcc/toplev.cc:319
0x7f26ce20a08f ???
   
/build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x2337afe rtl_ssa::insn_info::is_bb_head() const
../../gcc-trunk/gcc/rtl-ssa/member-fns.inl:610
0x2337afe rtl_ssa::can_insert_after(rtl_ssa::insn_info*)
../../gcc-trunk/gcc/rtl-ssa/movement.h:68
0x2337afe rtl_ssa::canonicalize_move_range(rtl_ssa::insn_range_info&,
rtl_ssa::insn_info*)
../../gcc-trunk/gcc/rtl-ssa/movement.h:78
0x2337afe restrict_movement_for_dead_range<(anonymous
namespace)::insn_combination::substitute_nondebug_use(rtl_ssa::use_info*)::local_ignore>
../../gcc-trunk/gcc/rtl-ssa/movement.h:163
0x2337afe add_regno_clobber<(anonymous
namespace)::insn_combination::substitute_nondebug_use(rtl_ssa::use_info*)::local_ignore>
../../gcc-trunk/gcc/rtl-ssa/member-fns.inl:982
0x2337afe operator()
../../gcc-trunk/gcc/rtl-ssa/change-utils.h:105
0x2337afe _M_invoke
/usr/include/c++/9/bits/std_function.h:285
0x2390667 std::function::operator()(rtl_ssa::insn_change&, unsigned int) const
/usr/include/c++/9/bits/std_function.h:688
0x2390667 add_clobber
../../gcc-trunk/gcc/rtl-ssa/changes.cc:934
0x2390667 recog_level2
../../gcc-trunk/gcc/rtl-ssa/changes.cc:1027
0x2391be8 rtl_ssa::recog_internal(rtl_ssa::insn_change&, std::function)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:1131
0x23389e9 recog<(anonymous
namespace)::insn_combination::substitute_nondebug_use(rtl_ssa::use_info*)::local_ignore>
../../gcc-trunk/gcc/rtl-ssa/change-utils.h:107
0x23389e9 substitute_nondebug_use
../../gcc-trunk/gcc/late-combine.cc:256
0x23389e9 substitute_nondebug_uses
../../gcc-trunk/gcc/late-combine.cc:270
0x23395c5 run
../../gcc-trunk/gcc/late-combine.cc:439
0x23395c5 combine_into_uses
../../gcc-trunk/gcc/late-combine.cc:683
0x2339db7 execute
../../gcc-trunk/gcc/late-combine.cc:711
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[538] % 
[538] % cat small.c
int a, b, c, d, e, f;
int main() {
  if (e && f)
while (1)
  while (a)
a = 0;
  if (c) {
if (b)
  goto g;
int h = a;
  i:
b = ~((b ^ h) | 1 % b);
if (a)
g:
  b = 0;
  }
  if (d)
goto i;
  return 0;
}

[Bug rtl-optimization/115928] New: ICE on valid code at -O2 with "-fgcse-sm" on x86_64-linux-gnu: in merge_clobber_groups, at rtl-ssa/accesses.cc:757

2024-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115928

Bug ID: 115928
   Summary: ICE on valid code at -O2 with "-fgcse-sm" on
x86_64-linux-gnu: in merge_clobber_groups, at
rtl-ssa/accesses.cc:757
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier. 

Compiler Explorer: https://godbolt.org/z/87jKGxq6E

[520] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240714 (experimental) (GCC) 
[521] % 
[521] % gcctk -O2 -fgcse-sm small.c
during RTL pass: late_combine
small.c: In function ‘main’:
small.c:21:1: internal compiler error: in merge_clobber_groups, at
rtl-ssa/accesses.cc:757
   21 | }
  | ^
0x24979f5 internal_error(char const*, ...)
../../gcc-trunk/gcc/diagnostic-global-context.cc:491
0xa462c6 fancy_abort(char const*, int, char const*)
../../gcc-trunk/gcc/diagnostic.cc:1725
0xa3015f rtl_ssa::function_info::merge_clobber_groups(rtl_ssa::clobber_info*,
rtl_ssa::clobber_info*, rtl_ssa::def_info*)
../../gcc-trunk/gcc/rtl-ssa/accesses.cc:757
0x238ea90 rtl_ssa::function_info::remove_def(rtl_ssa::def_info*)
../../gcc-trunk/gcc/rtl-ssa/accesses.cc:1040
0x2394cb1
rtl_ssa::function_info::change_insns(array_slice)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:852
0x233966a run
../../gcc-trunk/gcc/late-combine.cc:452
0x233966a combine_into_uses
../../gcc-trunk/gcc/late-combine.cc:683
0x2339db7 execute
../../gcc-trunk/gcc/late-combine.cc:711
0x2339db7 execute
../../gcc-trunk/gcc/late-combine.cc:760
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[522] % 
[522] % cat small.c
int a[1], b, c;
struct {
  int d;
  int e;
  int : 8;
} f[1];
static int g;
char h, i, j;
void k(int l) { b = 5 ^ a[b ^ (l & 5)]; }
void m(long l) { k(c >> 6); }
int main() {
  g++;
  if (b) {
h = 5 && j;
if (h)
  h -= i;
m(f[g].d);
m(f[g].e);
  }
  return 0;
}

[Bug tree-optimization/115927] New: wrong code at -O{2,3} with "-fno-tree-vrp" on x86_64-linux-gnu (nondeterministic behavior)

2024-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115927

Bug ID: 115927
   Summary: wrong code at -O{2,3} with "-fno-tree-vrp" on
x86_64-linux-gnu (nondeterministic behavior)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier. 

Compiler Explorer: https://godbolt.org/z/76naEWj7b

[582] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240714 (experimental) (GCC) 
[583] % 
[583] % gcctk -O2 small.c
[584] % ./a.out
0
[585] % gcctk -O2 -fno-tree-vrp small.c
[586] % ./a.out
[587] % ./a.out
[588] % ./a.out
0
[589] % ./a.out
0
[590] % cat small.c
int printf(const char *, ...);
int a, c, d;
long b;
char e;
int main() {
  d = 4 ^ a;
  e = (~(b & 5) & (0 || d) << c) % 4;
  if (e > 0)
printf("%d\n", a);
  return 0;
}

[Bug tree-optimization/115926] New: wrong code at -O1 with "-fno-tree-fre" on x86_64-linux-gnu

2024-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115926

Bug ID: 115926
   Summary: wrong code at -O1 with "-fno-tree-fre" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 11.* and affects 12.* and later. 

Compiler Explorer: https://godbolt.org/z/qG1rYens8

[516] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240714 (experimental) (GCC) 
[517] % 
[517] % gcctk -O1 small.c; ./a.out
[518] % 
[518] % gcctk -O1 -fno-tree-fre small.c
[519] % ./a.out
Segmentation fault
[520] % 
[520] % cat small.c
struct a {
  int b;
} const c;
int d;
void e(const struct a g) { d = 0; }
long f(const struct a g) {
  int h;
  e(g);
  h = g.b;
  return g.b;
}
int main() {
  f(c);
  return 0;
}

[Bug tree-optimization/115925] New: wrong code at -O{2,3} with "-fno-thread-jumps" on x86_64-linux-gnu

2024-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115925

Bug ID: 115925
   Summary: wrong code at -O{2,3} with "-fno-thread-jumps" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 13.*, and affects 14.1 and the trunk. 

Compiler Explorer: https://godbolt.org/z/dThxjfzf3

[521] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240714 (experimental) (GCC) 
[522] % 
[522] % gcctk -O2 small.c; ./a.out
[523] % 
[523] % gcctk -O2 -fno-thread-jumps small.c
[524] % ./a.out
1
[525] % cat small.c
int printf(const char *, ...);
int a, b, c = 1, d = 1, e, g;
char f;
int main() {
  int h = 10, i;
j:
  if (h < e) {
printf("%d\n", c);
return 0;
  }
  i = -1;
  if (d)
i = h;
  h = b = -2;
  a = (b ^ i) | (c || f);
  if (i <= a)
g = ~i;
  if (a > 0)
goto j;
  return 0;
}

[Bug rtl-optimization/115782] [15 Regression] ICE on valid code at -O{2,3} with "-fno-guess-branch-probability -fgcse-sm -fno-expensive-optimizations -fno-gcse" on x86_64-linux-gnu: in possibly_queue_

2024-07-11 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115782

--- Comment #2 from Zhendong Su  ---
Compiler Explorer: https://godbolt.org/z/MeKeYYjYq

Another reproducer for -O{2,3} without any other flags:

[550] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240711 (experimental) (GCC)
[551] %
[551] % gcctk -O2 small.c
during RTL pass: late_combine
small.c: In function ‘main’:
small.c:31:1: internal compiler error: in possibly_queue_changes, at
rtl-ssa/changes.cc:378
   31 | }
  | ^
0x2496472 internal_error(char const*, ...)
../../gcc-trunk/gcc/diagnostic-global-context.cc:491
0xa452f4 fancy_abort(char const*, int, char const*)
../../gcc-trunk/gcc/diagnostic.cc:1725
0xa2f3f3 rtl_ssa::function_info::possibly_queue_changes(rtl_ssa::insn_change&)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:378
0x2393115
rtl_ssa::function_info::change_insns(array_slice)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:779
0x233824a run
../../gcc-trunk/gcc/late-combine.cc:452
0x233824a combine_into_uses
../../gcc-trunk/gcc/late-combine.cc:683
0x2338997 execute
../../gcc-trunk/gcc/late-combine.cc:711
0x2338997 execute
../../gcc-trunk/gcc/late-combine.cc:760
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[552] %
[552] % cat small.c
int a, b, c, d, e, f;
int main() {
  int g, i = 4, j = 5;
  char h = 4;
  if (c) {
j = 0;
i = ~(d * 6);
if (a)
  goto k;
  }
  g = e;
  while (a) {
long l;
while (b) {
  int m = ~g;
o:
  l = m;
  char n;
  int q, p = h;
k:
  h = h % l - (-1 % q & (i || a));
  f = (f & p - l % n << h) % b;
  if (j)
continue;
  h = n;
  if (f)
goto o;
}
  }
  return 0;
}

[Bug rtl-optimization/115782] New: ICE on valid code at -O{2, 3} with "-fno-guess-branch-probability -fgcse-sm -fno-expensive-optimizations -fno-gcse" on x86_64-linux-gnu: in possibly_queue_changes, a

2024-07-04 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115782

Bug ID: 115782
   Summary: ICE on valid code at -O{2,3} with
"-fno-guess-branch-probability -fgcse-sm
-fno-expensive-optimizations -fno-gcse" on
x86_64-linux-gnu: in possibly_queue_changes, at
rtl-ssa/changes.cc:378
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier.

Compiler Explorer: https://godbolt.org/z/W788sGaq8

[518] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240704 (experimental) (GCC) 
[519] % 
[519] % gcctk -O2 small.c; ./a.out
[520] % 
[520] % gcctk -O2 -fno-guess-branch-probability -fgcse-sm
-fno-expensive-optimizations -fno-gcse small.c
during RTL pass: late_combine
small.c: In function ‘main’:
small.c:20:1: internal compiler error: in possibly_queue_changes, at
rtl-ssa/changes.cc:378
   20 | }
  | ^
0x248df42 internal_error(char const*, ...)
../../gcc-trunk/gcc/diagnostic-global-context.cc:491
0xa43fae fancy_abort(char const*, int, char const*)
../../gcc-trunk/gcc/diagnostic.cc:1725
0xa2e25f rtl_ssa::function_info::possibly_queue_changes(rtl_ssa::insn_change&)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:378
0x238b00e
rtl_ssa::function_info::change_insns(array_slice)
../../gcc-trunk/gcc/rtl-ssa/changes.cc:779
0x233014a run
../../gcc-trunk/gcc/late-combine.cc:452
0x233014a combine_into_uses
../../gcc-trunk/gcc/late-combine.cc:683
0x2330897 execute
../../gcc-trunk/gcc/late-combine.cc:711
0x2330897 execute
../../gcc-trunk/gcc/late-combine.cc:760
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[521] % 
[521] % cat small.c
int printf(const char *, ...);
int a, b, c, d, e, f, g, i, j, m, h;
long k, l, n, o;
int main() {
  int p = e, r = i << a, q = r & b;
  k = 4073709551613;
  l = m = c = -(c >> j);
  d = g ^ h ^ 4073709551613;
  n = q - h;
  o = ~d;
  f = c * 4073709551613 / 409725 ^ r;
  if ((n && m) || (q && j) || a)
return 0;
  d = o | p;
  if (g)
printf("0");
  d = p;
  c++;
  return 0;
}

[Bug ipa/115701] New: wrong code at -O1 and above with "-fipa-pta" on x86_64-linux-gnu

2024-06-28 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115701

Bug ID: 115701
   Summary: wrong code at -O1 and above with "-fipa-pta" on
x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ipa
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 9.*, and affects 10.* and later. 

Compiler Explorer: https://godbolt.org/z/szxjKcz8b

[537] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240628 (experimental) (GCC) 
[538] % 
[538] % gcctk -O1 small.c; ./a.out
[539] % 
[539] % gcctk -O1 -fipa-pta small.c
[540] % ./a.out
Aborted
[541] % 
[541] % cat small.c
int a, c, d;
static int b;
int main() {
  int *e = , **f = 
  while (1) {
int **g, ***h = 
if (c)
  *g = e;
else if (!b)
  break;
*e = **g;
e = 
  }
  if (e != )
__builtin_abort();
  return 0;
}

[Bug target/115671] New: wrong code at -O1 with "-fgcse -fno-inline -fschedule-insns" on x86_64-linux-gnu

2024-06-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115671

Bug ID: 115671
   Summary: wrong code at -O1 with "-fgcse -fno-inline
-fschedule-insns" on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It seems to be a recent regression as it doesn't reproduce with 14.1. 

Compiler Explorer: https://godbolt.org/z/Ev6hsWhE1

[648] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240626 (experimental) (GCC) 
[649] % 
[649] % gcctk -O1 small.c; ./a.out
[650] % 
[650] % gcctk -O1 -fgcse -fno-inline -fschedule-insns small.c
[651] % ./a.out
Aborted
[652] % 
[652] % cat small.c
int printf(const char *, ...);
int a, b, c, d, e;
short f[2];
int g(int h, int i) { return 0; }
int j(int h, int i) { return i; }
void k() {
  int l;
  for (; b < 1; b++) {
l = g(a, e);
c = l < a;
e = j(f[1 + b], 2);
d = a || d;
if (j(0, 1))
  return;
  }
}
int main() {
  k();
  if (c != 0)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/115661] wrong code at -O{2,3} on x86_64-linux-gnu

2024-06-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661

--- Comment #1 from Zhendong Su  ---
The following might be the same or related although it needs several flags to
trigger. 

Compiler Explorer: https://godbolt.org/z/Y9414PbTh

[567] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240626 (experimental) (GCC) 
[568] % 
[568] % gcctk -O2 small.c; ./a.out
[569] % 
[569] % gcctk -O2 -fno-tree-pre -fschedule-insns -fno-forward-propagate
-fno-guess-branch-probability -fno-gcse small.c
[570] % ./a.out
0
[571] % 
[571] % cat small.c
int printf(const char *, ...);
struct {
  unsigned : 8;
  volatile unsigned b : 1;
  int c : 31;
  int d : 5;
} g, k, m, n, p;
unsigned e = 5;
volatile int f = 1;
int h, i, l, o, r, q;
long j, a;
int main() {
  if (0)
  L:
for (; e; e++)
  ;
  for (; j < 5; j = 0)
if (f) {
  int t = 7 - (((k.d | 7) ^ m.c) - a) - ~(n.b & -o), u, v = -t ^ q,
  w = e - h;
  u = k.d;
  if (i) {
if (w > 6)
  goto L;
printf("%d", l);
  }
  g.d = (g.d & (n.b - 5)) - (-((k.d - 7 - o) & t) ^ (v & q));
  n.b = t;
  m.c = ~(t - (7L & m.c));
  k.d = ~(a & (m.c | ~o) & ~u) & g.d;
  if ((unsigned) p.d >= e)
printf("0\n");
  return 0;
}
  return 0;
}

[Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu

2024-06-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661

Bug ID: 115661
   Summary: wrong code at -O{2,3} 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it doesn't reproduce with 14.1.

Compiler Explorer: https://godbolt.org/z/1dneGGoTE

[517] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240626 (experimental) (GCC) 
[518] % 
[518] % gcctk -O0 small.c; ./a.out
[519] % gcctk -O2 small.c
[520] % ./a.out
0
[521] % cat small.c
int printf(const char *, ...);
int a, b[6], c = 2, d, e = 446984904, *g, h, *i = [5];
int *m() {
  int *f = 
  if (d < 6)
return [5];
  return f;
}
void n() {
  int j;
  for (; a < 1; a++)
for (j = 0; j < 1; j++) {
  g = m();
  int k = *g;
  if (k) {
int l = (3504049682 + e) & 3504049682;
h = ~(k * l) * 7455084268;
if (h > -1436818931) {
  printf("0\n");
  continue;
}
return;
  }
}
}
int main() {
  *i = 1;
  n();
  return 0;
}

[Bug tree-optimization/115579] [15 regression] wrong code at -Os with "-fno-tree-sra" on x86_64-linux-gnu since r15-1391-g4b75ed33fa5fd6

2024-06-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115579

--- Comment #3 from Zhendong Su  ---
Perhaps the same or a related issue.  It reproduces for -O{s,2,3}. 

Compiler Explorer: https://godbolt.org/z/x779P9b5a

[570] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240620 (experimental) (GCC) 
[571] % 
[571] % gcctk -O2 small.c; ./a.out
[572] % 
[572] % gcctk -O2 -fno-tree-fre -fno-tree-sra -fno-tree-ch -fno-tree-dce
small.c
[573] % ./a.out
Floating point exception
[574] % 
[574] % cat small.c
int a = 1;
int main() {
  int b[1], c;
  for (c = 0; c < 2; c++) {
int d = a, e = 1 / d;
while (!e) {
  b[0] = 0;
  while (b[0])
;
  a = 0;
}
  }
  return 0;
}

[Bug tree-optimization/115578] wrong code at -Os with " on x86_64-linux-gnu

2024-06-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115578

--- Comment #2 from Zhendong Su  ---
Sorry for this; not sure what happened

[Bug tree-optimization/115579] New: wrong code at -Os with "-fno-tree-sra" on x86_64-linux-gnu

2024-06-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115579

Bug ID: 115579
   Summary: wrong code at -Os with "-fno-tree-sra" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a very recent regression as it doesn't reproduce with 14.1. 

Compiler Explorer: https://godbolt.org/z/8qsq5zbeE


[572] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240620 (experimental) (GCC) 
[573] % 
[573] % gcctk -Os small.c; ./a.out
[574] % 
[574] % gcctk -Os -fno-tree-sra small.c
[575] % ./a.out
Aborted
[576] % 
[576] % cat small.c
int printf(const char *, ...);
int a, b = 1, c;
int main() {
  int d[2], *e = [1];
  while (a) {
int *f = 
d[1] = 0;
*f = 0;
  }
  if (c)
printf("%d\n", *e);
  if (b != 1)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/115578] New: wrong code at -Os with " on x86_64-linux-gnu

2024-06-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115578

Bug ID: 115578
   Summary: wrong code at -Os with " 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

[Bug tree-optimization/115568] New: wrong code at -O2 with "-fno-tree-sink -fno-tree-ter -fschedule-insns" on x86_64-linux-gnu

2024-06-20 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115568

Bug ID: 115568
   Summary: wrong code at -O2 with "-fno-tree-sink -fno-tree-ter
-fschedule-insns" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 11.*, and affects 12.* and later.

Compiler Explorer: https://godbolt.org/z/dT39sfGd6

[524] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240620 (experimental) (GCC) 
[525] % 
[525] % gcctk -O2 small.c; ./a.out
[526] % 
[526] % gcctk -O2 -fno-tree-sink -fno-tree-ter -fschedule-insns small.c
[527] % ./a.out
Floating point exception
[528] % 
[528] % cat small.c
int a, c, d = 1, e, f = 1, h, i, j;
unsigned b = 1, g;
int main() {
  for (; h < 2; h++) {
int k = ~(b || 0), l = ((~e - j) ^ a % b) % k, m = (b ^ -1) + e;
unsigned o = ~a % ~1;
if (f) {
  l = d;
  m = 10;
  i = e;
  d = -(~e + b);
  g = o % m;
  e = -1;
n:
  a = a % ~i;
  b = ~k;
  if (!g) {
b = e + o % -1;
continue;
  }
  if (!l)
break;
}
int q = (~d + g) << ~e, p = (~d - q) & a >> b;
unsigned s = ~((g & e) + (p | (b ^ (d + k;
int r = (e & s) + p, u = d | ~a,
t = ((~(q + (~a + (s + e & u) | (-g & (c << d ^ p));
if (t)
  if (!r)
goto n;
g = m;
e = i;
  }
  return 0;
}

[Bug rtl-optimization/115521] ICE at -O1 with "-fno-tree-ccp -fno-tree-dominator-opts" on x86_64-linux-gnu: in extract_constrain_insn, at recog.cc:2713

2024-06-17 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115521

--- Comment #4 from Zhendong Su  ---
(In reply to Andrew Pinski from comment #3)
> Dup then.
> 
> *** This bug has been marked as a duplicate of bug 114942 ***

Similar, but perhaps not a dup as PR114942 doesn't reproduce on the trunk
anymore.

[Bug tree-optimization/115521] New: ICE at -O1 with "-fno-tree-ccp -fno-tree-dominator-opts" on x86_64-linux-gnu: in extract_constrain_insn, at recog.cc:2713

2024-06-17 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115521

Bug ID: 115521
   Summary: ICE at -O1 with "-fno-tree-ccp
-fno-tree-dominator-opts" on x86_64-linux-gnu: in
extract_constrain_insn, at recog.cc:2713
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 13.* and
earlier. 

Compiler Explorer: https://godbolt.org/z/qEb7fcaf1

The reduced test is still quite big, but it seems difficult to get it to be
much smaller. 


[524] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240617 (experimental) (GCC) 
[525] % 
[525] % gcctk -O1 -fno-tree-ccp -fno-tree-dominator-opts -c -w small.c
small.c: In function ‘bi’:
small.c:188:1: error: insn does not satisfy its constraints:
  188 | }
  | ^
(insn 19 968 967 2 (parallel [
(set (strict_low_part (reg:QI 2 cx [orig:415 bj ] [415]))
(ior:QI (subreg:QI (zero_extract:HI (reg/v:HI 2 cx [orig:415 bj
] [415])
(const_int 8 [0x8])
(const_int 8 [0x8])) 0)
(reg:QI 0 ax [orig:99 c.3_4 ] [99])))
(clobber (reg:CC 17 flags))
]) "small.c":21:7 656 {*iorqi_exthi_1_slp}
 (nil))
during RTL pass: reload
small.c:188:1: internal compiler error: in extract_constrain_insn, at
recog.cc:2713
0x84dde4 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
../../gcc-trunk/gcc/rtl-error.cc:108
0x84de10 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
../../gcc-trunk/gcc/rtl-error.cc:118
0x84c04a extract_constrain_insn(rtx_insn*)
../../gcc-trunk/gcc/recog.cc:2713
0xf6aca7 check_rtl
../../gcc-trunk/gcc/lra.cc:2189
0xf70131 lra(_IO_FILE*, int)
../../gcc-trunk/gcc/lra.cc:2610
0xf2044f do_reload
../../gcc-trunk/gcc/ira.cc:5973
0xf2044f execute
../../gcc-trunk/gcc/ira.cc:6161
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[526] % 
[526] % cat small.c
typedef int a;
long b, c, ab, d, e, g, h, j, k, l, m, n, at;
a o, p, **q, r, aa, s, t, ac, ad, u, v, w, x, f;
unsigned ae, z, af;
short ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, y, ar, as;
static char au, av;
static volatile short aw;
a *ax, *ay, *az, *ba;
a **bb, **bc;
int bd();
char be();
void bf();
short bg();
long bh();
a *bi() {
  char bj[2];
  char *bk = [0];
  int i = 0;
  for (; i < 2; i++)
bj[i] = 0;
  *bk = c | bj[1];
  l = e = af = ac = 0;
  short bl[16] = {c, an, c, ao, an, ai, ag, c, ag, c, f, f, ag};
  char bm[] = {f, f, d, f, f, d, f}, bn = 0, bo = m && au;
  aw;
  if (b) {
int bp = 0, bq = 0, bs = o, bw = aj = an;
while (aw)
br:
  v = aa = --am;
while (au)
  ai = b = r = p = av;
as = s = c = 0;
az = bi();
b = f = be();
t = bd();
b = bg();
d = bg();
for (; b; ++at) {
  a *d = 
  for (; i; i++)
for (; c; ad++)
  c = e = b = bd();
  f = bg();
  ar = c = bg();
  f = be();
  *q = ba = bi();
}
an = c = av;
h = bh();
z = be();
d = bg();
e = i = be();
j = bh();
k = bh(++k);
v = be();
a *bt = , *bu = 
b = bd();
e = bg();
d = bg();
f = be();
*bc = *bb = bi();
  bv:
f = av;
f = bh();
y = bg();
n = bh();
{
  short f = aw, bz = au;
  aw;
  --ab;
  p = aw - av;
bx:
  ag = aw - ag;
  if (an || c && av) {
ag = aw ^ av;
goto by;
  }
  aw;
  aw;
  am = ai = au > 
  c = av;
  bd();
  if (av)
bd();
  am = av;
  bd();
}
an = aa = ag = e = bd();
char ca = b;
  by:
c = bg();
d = bh();
e = bh();
e = bh();
g = bh();
x = bg();
an = al > 
if (av)
  i = 0;
for (; i; i++)
  bd();
b = v = be();
*ba = b = bg();
c = p && bw;
if (bw)
  an = p = bg();
d = bd();
e = bg();
ay = bi();
b = be();
c = bd();
b = be();
f = bg();
while (au)
  d = bd();
e = bd();
bf();
long cb = am && au & av;
{
  short cc = b = aw, cd = aw || au, ce = 

[Bug tree-optimization/115494] New: wrong code at -O{2,3} with "-fno-ssa-phiopt" on x86_64-linux-gnu (the generated code hangs)

2024-06-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115494

Bug ID: 115494
   Summary: wrong code at -O{2,3} with "-fno-ssa-phiopt" on
x86_64-linux-gnu (the generated code hangs)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 13.* and
earlier. 

Compiler Explorer: https://godbolt.org/z/889EdEeE9

[627] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240614 (experimental) (GCC) 
[628] % 
[628] % gcctk -O2 small.c; ./a.out; echo $?
0
[629] % gcctk -O2 -fno-ssa-phiopt small.c; ./a.out; echo $?
1
[630] % cat small.c
unsigned char a;
int b = 1, c, d;
int main() {
  char e;
  c = b - c;
  a = ~(c || a);
  e = -(b ^ a);
  d = e && b;
  a = ~(b & a);
  if (a < 2)
return 1;
  return 0;
}

[Bug tree-optimization/115467] New: wrong code at -O1 with "-fno-tree-fre" on x86_64-linux-gnu

2024-06-12 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115467

Bug ID: 115467
   Summary: wrong code at -O1 with "-fno-tree-fre" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 11.* and affects 12.* and later.

Compiler Explorer: https://godbolt.org/z/o5PMfan4v


[530] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240612 (experimental) (GCC) 
[531] % 
[531] % gcctk -O1 small.c; ./a.out
[532] % 
[532] % gcctk -O1 -fno-tree-fre small.c
[533] % ./a.out
Segmentation fault
[534] % 
[534] % cat small.c
struct a {
  int b;
} const c;
int d;
void e(const struct a p, int q) { d = 0; }
void f(const struct a g) {
  e(g, g.b);
  g.b ^ d;
}
int main() {
  f(c);
  return 0;
}

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

2024-06-07 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115388

Bug ID: 115388
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier.

Compiler Explorer: https://godbolt.org/z/dzbaj98PM

[515] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240607 (experimental) (GCC) 
[516] % 
[516] % gcctk -O2 small.c; ./a.out
[517] % gcctk -O3 small.c
[518] % ./a.out
Aborted
[519] % cat small.c
int printf(const char *, ...);
int a[10], b, c, d[0], h, i, j, k, l;
char e = -1, g;
volatile int f;
static void n() {
  while (e >= 0)
while (1)
  ;
  for (b = 2; b >= 0; b--) {
for (k = 0; k < 4; k++) {
  if (e || i)
continue;
  for (h = 0; h < 2; h++)
f;
}
for (l = 2; l >= 0; l--)
  g = 0;
for (; g < 1; g++)
  if (c)
d[l] = 1;
a[9] = 0;
a[b] = 1;
while (j)
  printf("\n");
  }
}
int main() {
  n();
  if (a[1] != 1)
__builtin_abort();
  return 0;
}

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

2024-06-04 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115347

Bug ID: 115347
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 11.*, affecting 12.* and later.

Compiler Explorer: https://godbolt.org/z/PY985hnff

[510] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240604 (experimental) (GCC) 
[511] % 
[511] % gcctk -O2 small.c; ./a.out
[512] % gcctk -O3 small.c
[513] % ./a.out
Aborted
[514] % cat small.c
struct a {
  int b;
  int c;
} d, e[2];
int f, g, h;
int main() {
  for (; f < 1; f++) {
for (h = 0; h < 2; h++) {
  d = e[f];
  g = e[1].c;
  e[f].c = 1;
}
  }
  if (d.c != 1)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/115236] New: wrong code at -O1 and above with -fno-tree-fre on x86_64-linux-gnu

2024-05-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115236

Bug ID: 115236
   Summary: wrong code at -O1 and above with -fno-tree-fre 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier. 

Compiler Explorer: https://godbolt.org/z/xhY65cevr

[533] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240526 (experimental) (GCC) 
[534] % 
[534] % gcctk -O1 small.c; ./a.out
[535] % 
[535] % gcctk -O1 -fno-tree-fre small.c
[536] % ./a.out
Aborted
[537] % cat small.c
int a, *b = 
int main() {
  int *c, *volatile *d = 
  *d = b;
  if (c != )
__builtin_abort();
  return 0;
}

[Bug tree-optimization/115226] New: ICE on valid code at -O3 on x86_64-linux-gnu: verify_ssa failed

2024-05-25 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115226

Bug ID: 115226
   Summary: ICE on valid code at -O3 on x86_64-linux-gnu:
verify_ssa failed
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier. 

Compiler Explorer: https://godbolt.org/z/EK1hn9n4s


[538] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240525 (experimental) (GCC) 
[539] % 
[539] % gcctk -O3 small.c 
small.c: In function ‘main’:
small.c:3:5: error: stmt with wrong VUSE
3 | int main() {
  | ^~~~
# .MEM_4 = VDEF <.MEM_15>
a = 0;
expected .MEM_2
during GIMPLE pass: unswitch
small.c:3:5: internal compiler error: verify_ssa failed
0x140b2be verify_ssa(bool, bool)
../../gcc-trunk/gcc/tree-ssa.cc:1203
0x102deb5 execute_function_todo
../../gcc-trunk/gcc/passes.cc:2096
0x102e71e execute_todo
../../gcc-trunk/gcc/passes.cc:2143
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[540] % 
[540] % cat small.c
extern void c();
int a, b;
int main() {
  while (b) {
int d, e = 0, *f = 
*f = 1;
e = 1 >> d ? : 1 << d;
if (e)
  a = 0;
c();
  }
  return 0;
}

[Bug tree-optimization/115197] New: ICE on valid code at -O{1,2} with "-fno-tree-scev-cprop -ftree-pre -ftree-loop-distribute-patterns" on x86_64-linux-gnu: Segmentation fault

2024-05-22 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115197

Bug ID: 115197
   Summary: ICE on valid code at -O{1,2} with
"-fno-tree-scev-cprop -ftree-pre
-ftree-loop-distribute-patterns" on x86_64-linux-gnu:
Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 12.*, and affects 13.* and later.

Compiler Explorer: https://godbolt.org/z/aGqYsMjTv

[520] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240522 (experimental) (GCC) 
[521] % 
[521] % gcctk -O1 -fno-tree-scev-cprop -ftree-pre
-ftree-loop-distribute-patterns small.c
during GIMPLE pass: ldist
small.c: In function ‘main’:
small.c:2:5: internal compiler error: tree check: expected tree that contains
‘decl minimal’ structure, have ‘integer_cst’ in get_var_info, at
tree-into-ssa.cc:362
2 | int main() {
  | ^~~~
0x8c8f2f tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
../../gcc-trunk/gcc/tree.cc:9169
0x86647a contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
../../gcc-trunk/gcc/tree.h:3770
0x86647a get_var_info
../../gcc-trunk/gcc/tree-into-ssa.cc:362
0x86647a get_var_info
../../gcc-trunk/gcc/tree-into-ssa.cc:357
0x121a013 get_common_info
../../gcc-trunk/gcc/tree-into-ssa.cc:395
0x121a013 get_current_def(tree_node*)
../../gcc-trunk/gcc/tree-into-ssa.cc:404
0x122b69e copy_loop_before
../../gcc-trunk/gcc/tree-loop-distribution.cc:980
0x122b69e generate_loops_for_partition
../../gcc-trunk/gcc/tree-loop-distribution.cc:1020
0x122b69e generate_code_for_partition
../../gcc-trunk/gcc/tree-loop-distribution.cc:1381
0x122b69e loop_distribution::distribute_loop(loop*, vec const&, control_dependences*, int*, bool*, bool)
../../gcc-trunk/gcc/tree-loop-distribution.cc:3256
0x122be69 loop_distribution::execute(function*)
../../gcc-trunk/gcc/tree-loop-distribution.cc:3925
0x122cc0f execute
../../gcc-trunk/gcc/tree-loop-distribution.cc:4013
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[522] % 
[522] % cat small.c
int a, b[2], c, d, e, f[2];
int main() {
  while (a)
if (d) {
  if (e)
return 0;
  for (; c; c++)
f[c] = 0 < (b[c] = ~(f[c + 1] < a));
}
  return 0;
}

[Bug tree-optimization/115152] New: wrong code at -O3 with "-fno-tree-fre -fno-tree-dominator-opts -fno-tree-loop-im" on x86_64-linux-gnu

2024-05-18 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115152

Bug ID: 115152
   Summary: wrong code at -O3 with "-fno-tree-fre
-fno-tree-dominator-opts -fno-tree-loop-im" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a regression from 12.*, and affects 13.* and later. 

Compiler Explorer: https://godbolt.org/z/cvM1TYd7h


[598] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240516 (experimental) (GCC) 
[599] % 
[599] % gcctk -O3 small.c; ./a.out
[600] % 
[600] % gcctk -O3 -fno-tree-fre -fno-tree-dominator-opts -fno-tree-loop-im
small.c
[601] % ./a.out
Aborted
[602] % 
[602] % cat small.c
int a, b, c, d;
char e[1] = {1};
int main() {
  for (a = 0; a < 3; a++)
for (b = 0; b < 2; b++)
  c = e[0] = e[0] ^ d;
  if (!c)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/115149] New: ICE on valid code at -O3 with "-fno-inline -fno-tree-vrp -fno-ipa-sra -fno-tree-dce -fno-tree-ch" on x86_64-linux-gnu: verify_ssa failed

2024-05-18 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115149

Bug ID: 115149
   Summary: ICE on valid code at -O3 with "-fno-inline
-fno-tree-vrp -fno-ipa-sra -fno-tree-dce -fno-tree-ch"
on x86_64-linux-gnu: verify_ssa failed
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it doesn't reproduce with 14.1 and
earlier.

Compiler Explorer: https://godbolt.org/z/xGfY5vofe

[729] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240516 (experimental) (GCC) 
[730] % 
[730] % gcctk -O3 -fno-inline -fno-tree-vrp -fno-ipa-sra -fno-tree-dce
-fno-tree-ch small.c
small.c: In function ‘main’:
small.c:4:5: error: stmt with wrong VUSE
4 | int main() {
  | ^~~~
# VUSE <.MEM_16(D)>
c_lsm.18_25 = c;
expected .MEM_17
during GIMPLE pass: sink
small.c:4:5: internal compiler error: verify_ssa failed
0x140abbe verify_ssa(bool, bool)
../../gcc-trunk/gcc/tree-ssa.cc:1203
0x102ded5 execute_function_todo
../../gcc-trunk/gcc/passes.cc:2096
0x102e73e execute_todo
../../gcc-trunk/gcc/passes.cc:2143
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[731] % 
[731] % cat small.c
int a, c, e, f, g, h[1], i;
static int j(int b) { return 0; }
static void k(int d) {}
int main() {
  if (h[0])
while (1) {
  k(f && j(i && (h[g] = e)));
  while (a)
c ^= 1;
}
  return 0;
}

[Bug tree-optimization/115092] New: wrong code at -O1 with "-fgcse -ftree-pre -fno-tree-dominator-opts -fno-tree-fre -fno-guess-branch-probability" on x86_64-linux-gnu

2024-05-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115092

Bug ID: 115092
   Summary: wrong code at -O1 with "-fgcse -ftree-pre
-fno-tree-dominator-opts -fno-tree-fre
-fno-guess-branch-probability" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it only reproduces with 14.1 and trunk,
but not 13.* and earlier. It needs several flags, but hope it's still of
interest. 

Compiler Explorer: https://godbolt.org/z/qTc3e6s7f

[521] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240514 (experimental) (GCC) 
[522] % 
[522] % gcctk -O1 small.c; ./a.out
[523] % 
[523] % gcctk -O1 -fgcse -ftree-pre -fno-tree-dominator-opts -fno-tree-fre
-fno-guess-branch-probability small.c
[524] % ./a.out
Floating point exception
[525] % 
[525] % cat small.c
int a, b, c = 1, d, e;
int main() {
  int f, g = a;
  b = -2;
  f = -(1 >> ((c && b) & ~a));
  if (f <= b)
d = g / e;
  return 0;
}

[Bug tree-optimization/114998] New: ICE on valid code at -O3 with "-fno-inline -fno-tree-dce -fno-ipa-cp" on x86_64-linux-gnu: Segmentation fault

2024-05-08 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114998

Bug ID: 114998
   Summary: ICE on valid code at -O3 with "-fno-inline
-fno-tree-dce -fno-ipa-cp" on x86_64-linux-gnu:
Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It reproduces for 14.1 and trunk, but not 13.2 and earlier. 

Compiler Explorer: https://godbolt.org/z/7xjf7EWGs

[865] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240507 (experimental) (GCC)
[866] %
[866] % gcctk -O3 -fno-inline -fno-tree-dce -fno-ipa-cp small.c
during GIMPLE pass: ldist
small.c: In function ‘main’:
small.c:4:5: internal compiler error: Segmentation fault
4 | int main() {
  | ^~~~
0x1175773 crash_signal
../../gcc-trunk/gcc/toplev.cc:319
0x7f4aef65008f ???
   
/build/glibc-e2p3jK/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x140bb04 vec::quick_push(tree_node* const&)
../../gcc-trunk/gcc/vec.h:1043
0x140bb04 tree_node** vec_safe_push(vec*&, tree_node* const&)
../../gcc-trunk/gcc/vec.h:835
0x140bb04 release_ssa_name_fn(function*, tree_node*)
../../gcc-trunk/gcc/tree-ssanames.cc:619
0x1249bba release_ssa_name(tree_node*)
../../gcc-trunk/gcc/tree-ssanames.h:124
0x1249bba remove_phi_node(gimple_stmt_iterator*, bool)
../../gcc-trunk/gcc/tree-phinodes.cc:457
0x11bc34e gimple_merge_blocks
../../gcc-trunk/gcc/tree-cfg.cc:2175
0xbf0b63 merge_blocks(basic_block_def*, basic_block_def*)
../../gcc-trunk/gcc/cfghooks.cc:820
0x11cbc29 cleanup_tree_cfg_bb
../../gcc-trunk/gcc/tree-cfgcleanup.cc:791
0x11cd564 cleanup_tree_cfg_noloop
../../gcc-trunk/gcc/tree-cfgcleanup.cc:1122
0x11cd564 cleanup_tree_cfg(unsigned int)
../../gcc-trunk/gcc/tree-cfgcleanup.cc:1205
0x102c29c execute_function_todo
../../gcc-trunk/gcc/passes.cc:2058
0x102cb4e execute_todo
../../gcc-trunk/gcc/passes.cc:2143
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[867] %
[867] % cat small.c
short a, d;
int b, c, f, g, h, i, j[2], o;
void s(char r) {}
int main() {
  int l, m, k, n;
  if (b) {
char p;
for (; p >= 0; p--) {
  int e[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0,
 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1,
 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0};
  if (j[p]) {
int q[1];
i = o;
o = q[h];
if (g)
  n = d;
m = 4;
for (; m; m--) {
  if (l)
k |= c;
  if (a)
break;
}
  }
  s(n);
  f |= b;
}
  }
  return 0;
}

[Bug tree-optimization/114948] New: ICE on valid code at -O3 with "-fno-tree-ccp -fno-tree-ch" on x86_64-linux-gnu: in check_loop_closed_ssa_def, at tree-ssa-loop-manip.cc:647

2024-05-05 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114948

Bug ID: 114948
   Summary: ICE on valid code at -O3 with "-fno-tree-ccp
-fno-tree-ch" on x86_64-linux-gnu: in
check_loop_closed_ssa_def, at
tree-ssa-loop-manip.cc:647
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 13.2 and
earlier.

Compiler Explorer: https://godbolt.org/z/szY6nz1W3

[522] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240505 (experimental) (GCC) 
[523] % 
[523] % gcctk -O3 -fno-tree-ccp -fno-tree-ch small.c
during GIMPLE pass: cunroll
small.c: In function ‘main’:
small.c:2:5: internal compiler error: in check_loop_closed_ssa_def, at
tree-ssa-loop-manip.cc:647
2 | int main() {
  | ^~~~
0x89471d check_loop_closed_ssa_def
../../gcc-trunk/gcc/tree-ssa-loop-manip.cc:647
0x130e654 check_loop_closed_ssa_bb
../../gcc-trunk/gcc/tree-ssa-loop-manip.cc:661
0x131023e verify_loop_closed_ssa(bool, loop*)
../../gcc-trunk/gcc/tree-ssa-loop-manip.cc:697
0x131023e verify_loop_closed_ssa(bool, loop*)
../../gcc-trunk/gcc/tree-ssa-loop-manip.cc:681
0x12f54fe tree_unroll_loops_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1569
0x12f5583 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1673
0x12f5583 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1663
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[524] % 
[524] % cat small.c
int a, b, c, d;
int main() {
  int *e = 0;
  for (; d; d++)
  L1:
;
 L2:
   if (a) {
 for (c = 0; c < 2; ++c) {
   int *h;
   int **i = 
   int **const *j = 
   int **const **k = 
   if (c) {
 if (b)
   goto L2;
 a = *e;
   }
 }
 goto L1;
   }
 return 0;
}

[Bug rtl-optimization/114942] New: ICE on valid code at -O1 with "-fno-tree-sra -fno-guess-branch-probability": in extract_constrain_insn, at recog.cc:2713

2024-05-03 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114942

Bug ID: 114942
   Summary: ICE on valid code at -O1 with "-fno-tree-sra
-fno-guess-branch-probability": in
extract_constrain_insn, at recog.cc:2713
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 13.2 and
earlier.

Compiler Explorer: https://godbolt.org/z/av9hr4933

[648] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240503 (experimental) (GCC)
[649] %
[649] % gcctk -O1 -c -fno-tree-sra -fno-guess-branch-probability small.c
small.c: In function ‘main’:
small.c:21:1: error: insn does not satisfy its constraints:
   21 | }
  | ^
(insn 39 56 57 6 (parallel [
(set (strict_low_part (reg:QI 2 cx [orig:108 f ] [108]))
(ior:QI (subreg:QI (zero_extract:HI (reg/v:HI 2 cx [orig:108 f
] [108])
(const_int 8 [0x8])
(const_int 8 [0x8])) 0)
(reg:QI 0 ax [orig:121 _7 ] [121])))
(clobber (reg:CC 17 flags))
]) "small.c":19:7 626 {*iorqi_exthi_1_slp}
 (nil))
during RTL pass: reload
small.c:21:1: internal compiler error: in extract_constrain_insn, at
recog.cc:2713
0x83dea6 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
../../gcc-trunk/gcc/rtl-error.cc:108
0x83ded2 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
../../gcc-trunk/gcc/rtl-error.cc:118
0x83c10c extract_constrain_insn(rtx_insn*)
../../gcc-trunk/gcc/recog.cc:2713
0xf55a67 check_rtl
../../gcc-trunk/gcc/lra.cc:2189
0xf5aef1 lra(_IO_FILE*, int)
../../gcc-trunk/gcc/lra.cc:2610
0xf0b1ff do_reload
../../gcc-trunk/gcc/ira.cc:5973
0xf0b1ff execute
../../gcc-trunk/gcc/ira.cc:6161
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[650] %
[650] % cat small.c
extern void a();
struct b {
  char c;
  char d;
} e;
int main() {
  struct b f = e;
  char i = 0;
 L1:
  if (!f.c)
goto L2;
  if (e.c)
a();
  else
return 0;
  f.d = 0;
  i = 1 % ((1 & f.c) - 2);
 L2:
  f.c = ~(i & ~f.d);
  goto L1;
}

[Bug tree-optimization/114902] New: wrong code at -O3 with "-fno-tree-vrp -fno-expensive-optimizations -fno-tree-dominator-opts" on x86_64-linux-gnu

2024-04-30 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114902

Bug ID: 114902
   Summary: wrong code at -O3 with "-fno-tree-vrp
-fno-expensive-optimizations -fno-tree-dominator-opts"
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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it doesn't reproduce with 13.2. 

Compiler Explorer: https://godbolt.org/z/7ssP5W57E


[587] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240430 (experimental) (GCC) 
[588] % 
[588] % gcctk -O3 -fno-tree-vrp -fno-expensive-optimizations
-fno-tree-dominator-opts small.c
[589] % ./a.out
Floating point exception
[590] % 
[590] % gcctk -O3 small.c; ./a.out
[591] % 
[591] % cat small.c
volatile int a, c;
unsigned b = 1;
int main() {
  for (; a < 2; a++)
if (a)
  for (; c < 2; c++) {
int d = -1, e = -(-d & ~b), f = -~(1 && b % a);
a % f || a;
if (d <= e)
  e = a;
a = e;
  }
  return 0;
}

[Bug tree-optimization/114864] New: wrong code at -O1 with "-fno-tree-dce -fno-tree-fre" on x86_64-linux-gnu

2024-04-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114864

Bug ID: 114864
   Summary: wrong code at -O1 with "-fno-tree-dce -fno-tree-fre"
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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a regression from 11.*, and affects 12.* and later. 

Compiler Explorer: https://godbolt.org/z/TbYj469r3

[588] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240426 (experimental) (GCC) 
[589] % 
[589] % gcctk -O1 small.c; ./a.out
[590] % 
[590] % gcctk -O1 -fno-tree-dce -fno-tree-fre small.c
[591] % ./a.out
Segmentation fault
[592] % 
[592] % cat small.c
struct a {
  int b;
} const c;
void d(const struct a f) {}
void e(const struct a f) {
  f.b == 0 ? 1 : f.b;
  d(f);
}
int main() {
  e(c);
  return 0;
}

[Bug tree-optimization/114832] New: ICE at -O{2,3} with "-fno-tree-loop-if-convert -fno-tree-loop-distribute-patterns -ftree-vectorize" on x86_64-linux-gnu: in verify_dominators, at dominance.cc:1194

2024-04-23 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114832

Bug ID: 114832
   Summary: ICE at -O{2,3} with "-fno-tree-loop-if-convert
-fno-tree-loop-distribute-patterns -ftree-vectorize"
on x86_64-linux-gnu: in verify_dominators, at
dominance.cc:1194
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression and does not reproduce with 13.2 and
earlier.

Compiler Explorer: https://godbolt.org/z/1do4bc9W7


[515] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240423 (experimental) (GCC) 
[516] % 
[516] % gcctk -c -O2 -fno-tree-loop-if-convert
-fno-tree-loop-distribute-patterns -ftree-vectorize small.c 
small.c: In function ‘e’:
small.c:2:6: error: dominator of 6 should be 13, not 5
2 | void e() {
  |  ^
during GIMPLE pass: vect
small.c:2:6: internal compiler error: in verify_dominators, at
dominance.cc:1194
0x7a1828 verify_dominators(cdi_direction)
../../gcc-trunk/gcc/dominance.cc:1194
0x145a0d0 checking_verify_dominators(cdi_direction)
../../gcc-trunk/gcc/dominance.h:76
0x145a0d0 slpeel_tree_duplicate_loop_to_edge_cfg(loop*, edge_def*, loop*,
edge_def*, edge_def*, edge_def**, bool, vec*)
../../gcc-trunk/gcc/tree-vect-loop-manip.cc:1961
0x145d46c vect_do_peeling(_loop_vec_info*, tree_node*, tree_node*, tree_node**,
tree_node**, tree_node**, int, bool, bool, tree_node**)
../../gcc-trunk/gcc/tree-vect-loop-manip.cc:3444
0x144cd58 vect_transform_loop(_loop_vec_info*, gimple*)
../../gcc-trunk/gcc/tree-vect-loop.cc:11910
0x149374e vect_transform_loops
../../gcc-trunk/gcc/tree-vectorizer.cc:1006
0x1493e53 try_vectorize_loop_1
../../gcc-trunk/gcc/tree-vectorizer.cc:1152
0x1493e53 try_vectorize_loop
../../gcc-trunk/gcc/tree-vectorizer.cc:1182
0x149448c execute
../../gcc-trunk/gcc/tree-vectorizer.cc:1298
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[517] % 
[517] % cat small.c
int a, b, c, d[3];
void e() {
  int f, g = 0;
  for (; g < 3; g++) {
if (f || a || b && c) {
  int h, *i = , **j = 
}
d[g] = 0;
  }
}

[Bug rtl-optimization/114828] New: ICE on valid code at -O1 with "-ftree-pre -fselective-scheduling -fsel-sched-pipelining -fschedule-insns" on x86_64-linux-gnu: Segmentation fault

2024-04-23 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114828

Bug ID: 114828
   Summary: ICE on valid code at -O1 with "-ftree-pre
-fselective-scheduling -fsel-sched-pipelining
-fschedule-insns" on x86_64-linux-gnu: Segmentation
fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression and does not reproduce with 13.2 and
earlier.

Compiler Explorer: https://godbolt.org/z/9WdTv4qEe

[576] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240423 (experimental) (GCC)
[577] %
[577] % gcctk -c -O1 -ftree-pre -fselective-scheduling -fsel-sched-pipelining
-fschedule-insns small.c
during RTL pass: sched1
small.c: In function ‘f’:
small.c:14:1: internal compiler error: Segmentation fault
   14 | }
  | ^
0x116dc33 crash_signal
../../gcc-trunk/gcc/toplev.cc:319
0x7f3e0a2c608f ???
   
/build/glibc-e2p3jK/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x110b3d4 init_expr
../../gcc-trunk/gcc/sel-sched-ir.cc:1642
0x110b3d4 copy_expr_onside(_expr*, _expr*)
../../gcc-trunk/gcc/sel-sched-ir.cc:1685
0x111b549 move_op_orig_expr_found
../../gcc-trunk/gcc/sel-sched.cc:5997
0x111f2e0 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6551
0x11200fe code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6350
0x11200fe code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6616
0x11200fe code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6350
0x11200fe code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6616
0x11238e8 move_op
../../gcc-trunk/gcc/sel-sched.cc:6710
0x11238e8 move_exprs_to_boundary
../../gcc-trunk/gcc/sel-sched.cc:5231
0x11238e8 schedule_expr_on_boundary
../../gcc-trunk/gcc/sel-sched.cc:5444
0x1125588 fill_insns
../../gcc-trunk/gcc/sel-sched.cc:5586
0x1125588 schedule_on_fences
../../gcc-trunk/gcc/sel-sched.cc:7361
0x1125588 sel_sched_region_2
../../gcc-trunk/gcc/sel-sched.cc:7499
0x1126c78 sel_sched_region_1
../../gcc-trunk/gcc/sel-sched.cc:7541
0x1128a19 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7642
0x1128a19 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7627
0x1129a21 run_selective_scheduling()
../../gcc-trunk/gcc/sel-sched.cc:7728
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[578] %
[578] % cat small.c
char a, b;
int c, d, e;
void f() {
  char g = -1;
 L:
  if (e) {
e = b;
b = c % (d || ~g) && a % c;
c = c || a ^ d;
a = e || a + d + 1;
f();
goto L;
  }
}

[Bug tree-optimization/114796] New: wrong code at -O2 with "-fno-tree-fre -fno-inline -fselective-scheduling2" on x86_64-linux-gnu

2024-04-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114796

Bug ID: 114796
   Summary: wrong code at -O2 with "-fno-tree-fre -fno-inline
-fselective-scheduling2" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This seems quite long-latent and affects all versions 9.* and later. 

Compiler Explorer: https://godbolt.org/z/nKx6f4hjK

[526] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240421 (experimental) (GCC) 
[527] % 
[527] % gcctk -O0 small.c
[528] % ./a.out
[529] % 
[529] % gcctk -O2 -fno-tree-fre -fno-inline -fselective-scheduling2 small.c
[530] % ./a.out
Aborted
[531] % 
[531] % cat small.c
int printf(const char *, ...);
int a, b, c = -3, h, j, k;
struct d {
  int e;
  char f;
  char g;
};
int i, l, m;
char n[10][9] = {{1}};
struct d o = {1,0,0};
unsigned p;
void q(int s) { b = a; }
void r() {
  k = 0;
  while (k)
while (l)
  while (i)
if (m)
  while (1)
;
  for (; p < 1; p++) {
if (j) {
  q(n[j][c]);
  if (h)
printf("\n");
}
n[p][k] = 1;
  }
}
int main() {
  r();
  if (o.g != 0)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/114793] wrong code at -O1 with "-fschedule-insns2 -fselective-scheduling2" on x86_64-linux-gnu (the generated code hangs)

2024-04-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114793

--- Comment #1 from Zhendong Su  ---
The following reproducer is different, but perhaps is the same or related.

Compiler Explorer: https://godbolt.org/z/411rzMP1n

[588] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240421 (experimental) (GCC) 
[589] % 
[589] % gcctk -O1 -fno-tree-forwprop -fselective-scheduling2 -fschedule-insns2
-fsel-sched-pipelining small.c
[590] % ./a.out
Aborted
[591] % 
[591] % cat small.c
int printf(const char *, ...);
int a, d, g, h;
volatile int b = 1;
static unsigned c = 1;
char e, f = 1, i;
static int j() {
  int k, l = g, m = 1 << l, n = -e, o = -1 % ((f && 1) ^ i), p = ~n - o;
  if (m) {
int q, s, t, r = 1 % (((1 % f) & (~e | c)) ^ b);
q = f;
s = i;
t = e;
f = -b;
k = f;
d = -1;
  u:
e = 0 & b;
if (i > f)
  if (!b)
goto v;
if (d > t)
  __builtin_abort();
if (b < 1 || !d || !c) {
  printf("%d\n", i);
  f = ((i | b) & (k - r)) << (e << ~t ^ q) << s;
  goto u;
}
if (i)
  f = q;
  v:
i = n & o & l;
printf("%ld\n", (long)t);
  }
  i = p;
  return h;
}
int main() {
  for (; a < 3; a++)
j();
  return 0;
}

[Bug tree-optimization/114793] New: wrong code at -O1 with "-fschedule-insns2 -fselective-scheduling2" on x86_64-linux-gnu (the generated code hangs)

2024-04-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114793

Bug ID: 114793
   Summary: wrong code at -O1 with "-fschedule-insns2
-fselective-scheduling2" on x86_64-linux-gnu (the
generated code hangs)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It seems to be a recent regression as it does not reproduce with 13.2 and
earlier.

Compiler Explorer: https://godbolt.org/z/b3cc1MqP9

[538] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240421 (experimental) (GCC) 
[539] % 
[539] % gcctk -O0 small.c
[540] % ./a.out
[541] % 
[541] % gcctk -O1 -fschedule-insns2 -fselective-scheduling2 small.c
[542] % timeout -s 9 10 ./a.out
Killed
[543] % 
[543] % cat small.c
int printf(const char *, ...);
volatile int a;
int b, c, d = 1, e, f;
int main() {
  int g = 1;
  for (; b; b -= d)
g = e;
  for (; c < 2; c++) {
if (g) {
  if (!d)
printf("%d", f);
  continue;
}
a;
  }
  return 0;
}

[Bug tree-optimization/114792] New: ICE on valid code at -O1 with "-fno-tree-ccp -fno-tree-copy-prop" on x86_64-linux-gnu: in get_loop_body, at cfgloop.cc:903

2024-04-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114792

Bug ID: 114792
   Summary: ICE on valid code at -O1 with "-fno-tree-ccp
-fno-tree-copy-prop" on x86_64-linux-gnu: in
get_loop_body, at cfgloop.cc:903
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression and does not reproduce with 13.2. 

Compiler Explorer: https://godbolt.org/z/zzdjrb599


[522] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240421 (experimental) (GCC) 
[523] % 
[523] % gcctk -O1 -fno-tree-ccp -fno-tree-copy-prop small.c
during GIMPLE pass: ch
small.c: In function ‘main’:
small.c:2:5: internal compiler error: in get_loop_body, at cfgloop.cc:903
2 | int main() {
  | ^~~~
0x7926fd get_loop_body(loop const*)
../../gcc-trunk/gcc/cfgloop.cc:903
0xbfbce9 unloop(loop*, bool*, bitmap_head*)
../../gcc-trunk/gcc/cfgloopmanip.cc:1014
0x12ee996 unloop_loops(vec&, vec&, vec&, bitmap_head*, bool*)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:688
0x12dfc84 copy_headers
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1158
0x12e02da execute
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1179
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[524] % 
[524] % cat small.c
int a;
int main() {
  int b = -1, c;
  for (; b >= 0; b++) {
for (c = 0; c; c++) {
L:
  while (a)
if (a)
  goto L;
}
  }
  return 0;
}

[Bug rtl-optimization/114788] New: ICE on valid code at -O{2,3} on x86_64-linux-gnu (during RTL pass: sched2): in move_exprs_to_boundary, at sel-sched.cc:5236

2024-04-20 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114788

Bug ID: 114788
   Summary: ICE on valid code at -O{2,3} on x86_64-linux-gnu
(during RTL pass: sched2): in move_exprs_to_boundary,
at sel-sched.cc:5236
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It is a regression from 12.*, and affects 13.* and later. 

Compiler Explorer: https://godbolt.org/z/n4MvPos5n

[679] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240420 (experimental) (GCC)
[680] %
[680] % gcctk -O3 -fno-guess-branch-probability -fselective-scheduling2
-fno-tree-sink -fschedule-insns -c small.c
during RTL pass: sched2
small.c: In function ‘main’:
small.c:32:1: internal compiler error: in move_exprs_to_boundary, at
sel-sched.cc:5236
   32 | }
  | ^
0x8424f2 move_exprs_to_boundary
../../gcc-trunk/gcc/sel-sched.cc:5236
0x8424f2 schedule_expr_on_boundary
../../gcc-trunk/gcc/sel-sched.cc:5444
0x1125588 fill_insns
../../gcc-trunk/gcc/sel-sched.cc:5586
0x1125588 schedule_on_fences
../../gcc-trunk/gcc/sel-sched.cc:7361
0x1125588 sel_sched_region_2
../../gcc-trunk/gcc/sel-sched.cc:7499
0x1126c78 sel_sched_region_1
../../gcc-trunk/gcc/sel-sched.cc:7541
0x1128a19 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7642
0x1128a19 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7627
0x1129a21 run_selective_scheduling()
../../gcc-trunk/gcc/sel-sched.cc:7728
0x1106c0d rest_of_handle_sched2
../../gcc-trunk/gcc/sched-rgn.cc:3741
0x1106c0d execute
../../gcc-trunk/gcc/sched-rgn.cc:3888
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[681] % cat small.c
extern void r();
int b, d, g, l;
char c, e, f;
volatile char h;
int main() {
  int k, i, m, q;
  for (; b && i; i++) {
int n = k;
  L1:
k = 0 || d;
while (n < e)
  ;
  }
  b = f;
 L2:
  if (h)
r();
  if (l) {
int a, j = f / g, o = (j / c && f) % d, p = (f % q * ~h && c && j) / k;
if (h) {
  a = d;
  p = m;
  k = k / l / (2 * f % 3);
  m = o & c / ((m && a) ^ (p && 2 / g) | f);
  if (m)
goto L1;
}
m = p;
goto L2;
  }
  return 0;
}

[Bug tree-optimization/114787] New: wrong code at -O1 on x86_64-linux-gnu (the generated code hangs)

2024-04-20 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114787

Bug ID: 114787
   Summary: wrong code at -O1 on x86_64-linux-gnu (the generated
code hangs)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression and does not reproduce with 13.2 and
earlier. 

Compiler Explorer: https://godbolt.org/z/6sbh8Wr1e


[663] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240420 (experimental) (GCC) 
[664] % 
[664] % gcctk -O0 small.c; ./a.out
[665] % 
[665] % gcctk -O1 small.c
[666] % timeout -s 9 10 ./a.out
Killed
[667] % 
[667] % cat small.c
int a, b, c, d, e = -1, f, g, h, j, k, n, o, p;
int main() {
  int i, l = 2, m;
  for (b = 0; b < 1; b++)
l = 0;
  for (; a >= 0; a--)
for (m = 3; m; m--) {
  k = g;
  i = 0;
  for (; i < 1; i++)
for (; f < 1; f++)
  h = g;
  n = 2 & ((e ^ d) | 1) * j;
  o = ~(e & n);
q:
  if (c <= e)
return 0;
  e = o;
}
  p = l;
  l = 0;
  if (p)
goto q;
  return 0;
}

[Bug middle-end/114624] New: ICE on valid code at -O3 on x86_64-linux-gnu: Segmentation fault

2024-04-07 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114624

Bug ID: 114624
   Summary: ICE on valid code at -O3 on x86_64-linux-gnu:
Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/neef45W14

[516] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240405 (experimental) (GCC)
[517] %
[517] % gcctk -O3 small.c
during GIMPLE pass: sccp
small.c: In function ‘main’:
small.c:2:5: internal compiler error: Segmentation fault
2 | int main() {
  | ^~~~
0x116b653 crash_signal
../../gcc-trunk/gcc/toplev.cc:319
0x7fe51d50a08f ???
   
/build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x249ec06 get_data_from_adhoc_loc(line_maps const*, unsigned int)
../../gcc-trunk/libcpp/line-map.cc:297
0x11b8216 verify_location
../../gcc-trunk/gcc/tree-cfg.cc:5384
0x11bc50f verify_gimple_in_cfg(function*, bool, bool)
../../gcc-trunk/gcc/tree-cfg.cc:5600
0x10292b4 execute_function_todo
../../gcc-trunk/gcc/passes.cc:2089
0x1029c0e execute_todo
../../gcc-trunk/gcc/passes.cc:2143
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[518] %
[518] % cat small.c
int a, b;
int main() {
  int c, d = 1;
  while (a) {
while (b)
  if (d)
while (a)
  ;
for (; b < 2; b++)
  if (b)
for (c = 0; c < 8; c++)
  d = 0;
  else
for (a = 0; a < 2; a++)
  ;
  }
  return 0;
}

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

2024-04-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114552

Bug ID: 114552
   Summary: wrong code at -O1 and above 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It is a regression from 12.3, and affects 13.* and the trunk. 

Compiler Explorer: https://godbolt.org/z/bznEs9bao

[656] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240401 (experimental) (GCC) 
[657] % 
[657] % gcctk -O0 small.c; ./a.out
[658] % 
[658] % gcctk -O1 small.c
[659] % ./a.out
Segmentation fault
[660] % 
[660] % cat small.c
#pragma pack(1)
struct a {
  short b;
  int c;
};
struct d {
  struct a b;
  int e;
};
short f, g, h;
int i, j, o;
const struct d k = {{1,0},0};
short *l = , *m = , *n = 
void p() { *n = (o > 0) > o; }
void q(struct a n) {
  j = 0;
  for (; j < 5; j++)
i = *m = *l != 0;
  p();
}
int main() {
  q(k.b);
  return 0;
}

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

2024-04-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114551

Bug ID: 114551
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression as it does not reproduce for 13.2 and
earlier. 

Compiler Explorer: https://godbolt.org/z/q3hrz8MW1

[587] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240401 (experimental) (GCC) 
[588] % 
[588] % gcctk -O2 small.c; ./a.out
[589] % 
[589] % gcctk -O3 small.c
[590] % ./a.out
Segmentation fault
[591] % 
[591] % cat small.c
int a, b[4], c, d, e, f;
int main() {
  a--;
  for (f = 3; f >= 0; f--) {
for (e = 0; e < 4; e++)
  c = 0;
for (; c < 4; c++) {
  d = f && a > 0 && f > (2147483647 - a) ? 0 : b[f];
  continue;
}
  }
  return 0;
}

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

2024-02-23 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114074

Bug ID: 114074
   Summary: wrong code at -O1 and above 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This seems to be quite long-latent and affects 8.1 and later.

Compiler Explorer: https://godbolt.org/z/vbM6zsq1b

[511] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240223 (experimental) (GCC) 
[512] % 
[512] % gcctk -O0 small.c; ./a.out
0
0
[513] % gcctk -O1 small.c
[514] % ./a.out
0
[515] % cat small.c
int printf(const char *, ...);
int a, b;
int main() {
  for (a = 0; a > -3; a -= 2) {
int c = a;
b = 20;
a = ~c * b;
printf("0\n");
if (!a)
  break;
a = c;
  }
  return 0;
}

[Bug tree-optimization/113895] [14 Regression] ice in in copy_reference_ops_from_ref, at tree-ssa-sccvn.cc:1144

2024-02-13 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113895

--- Comment #8 from Zhendong Su  ---
Another likely related one (though ICE during a different pass and at a
different location):

[519] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240213 (experimental) (GCC) 
[520] % 
[520] % gcctk -O1 small.c
during GIMPLE pass: fre
small.c: In function ‘main’:
small.c:8:1: internal compiler error: in copy_reference_ops_from_ref, at
tree-ssa-sccvn.cc:1165
8 | }
  | ^
0x863773 copy_reference_ops_from_ref
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:1165
0x1298f9a valueize_shared_reference_ops_from_ref
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:1858
0x1298f9a valueize_shared_reference_ops_from_ref
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:1853
0x1298f9a vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind,
vn_reference_s**, bool, tree_node**, tree_node*, bool)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:4063
0x129d8b4 visit_reference_op_load
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:5852
0x129d8b4 visit_stmt
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:6373
0x129df5f process_bb
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8145
0x129f81e do_rpo_vn_1
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8746
0x12a1253 execute
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8907
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[521] % 
[521] % cat small.c
extern void f();
char a[1][1], b;
int main() {
  int c = -1U;
  if (b)
f(a[c][b]);
  return 0;
}

[Bug tree-optimization/113895] [14 Regression] ice in in copy_reference_ops_from_ref, at tree-ssa-sccvn.cc:1144

2024-02-12 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113895

Zhendong Su  changed:

   What|Removed |Added

 CC||zhendong.su at inf dot ethz.ch

--- Comment #2 from Zhendong Su  ---
Another related test:

[534] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240213 (experimental) (GCC) 
[535] % 
[535] % gcctk -O1 small.c
during GIMPLE pass: cunroll
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in copy_reference_ops_from_ref, at
tree-ssa-sccvn.cc:1156
3 | int main() {
  | ^~~~
0x86357f copy_reference_ops_from_ref
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:1156
0x1298c4a valueize_shared_reference_ops_from_ref
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:1837
0x1298c4a valueize_shared_reference_ops_from_ref
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:1832
0x1298c4a vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind,
vn_reference_s**, bool, tree_node**, tree_node*, bool)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:4042
0x129d574 visit_reference_op_load
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:5831
0x129d574 visit_stmt
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:6352
0x129dc1f process_bb
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8124
0x129f4de do_rpo_vn_1
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8725
0x12a0e53 do_rpo_vn(function*, edge_def*, bitmap_head*, bool, bool, bool,
vn_lookup_kind)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8829
0x11f6529 tree_unroll_loops_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1554
0x11f6663 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1673
0x11f6663 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1663
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[536] % 
[536] % cat small.c
extern void d(int);
int a[2][4], b;
int main() {
  while (b) {
int c;
d(a[b][c]);
for (c = 0; c < 7; c++)
  ;
  }
  return 0;
}

[Bug tree-optimization/113707] [14 Regression] ICE on valid code at -O1 on x86_64-linux-gnu: Segmentation fault since r14-8683

2024-02-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113707

--- Comment #2 from Zhendong Su  ---
Another related test for -O3 (only):

[555] % gcctk -O3 small.c
during GIMPLE pass: cunroll
small.c: In function ‘main’:
small.c:14:5: internal compiler error: Segmentation fault
   14 | int main() {
  | ^~~~
0x1161623 crash_signal
../../gcc-trunk/gcc/toplev.cc:317
0x7fa97fd5308f ???
   
/build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xda0c28 extract_ops_from_tree(tree_node*, tree_code*, tree_node**,
tree_node**, tree_node**)
../../gcc-trunk/gcc/gimple-expr.cc:530
0xd980e0 gimple_build_assign(tree_node*, tree_node*)
../../gcc-trunk/gcc/gimple.cc:454
0x137c91c eliminate_dom_walker::eliminate_cleanup(bool)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:7494
0x13917db do_rpo_vn_1
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8720
0x13923b3 do_rpo_vn(function*, edge_def*, bitmap_head*, bool, bool, bool,
vn_lookup_kind)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8749
0x12df179 tree_unroll_loops_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1554
0x12df2b3 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1673
0x12df2b3 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1663
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[556] %
[556] % cat small.c
int a, b, c, d, e, f, g, h, j, k, l;
void n() {
  while (c)
if (1) {
  for (h = 5; h; h--) {
int m = e % 2;
d = ~g || h ^ m / -1;
if (h > 5)
  e = k;
  }
  return;
}
}
int main() {
  if (a)
for (int i = 0; i < 2; i++) {
  for (f = 1; f < 6; f++)
for (c = 7; c >= 0; c--)
  if (l)
b = 0;
  n();
}
  return 0;
}

[Bug tree-optimization/113707] New: ICE on valid code at -O1 on x86_64-linux-gnu: Segmentation fault

2024-02-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113707

Bug ID: 113707
   Summary: ICE on valid code at -O1 on x86_64-linux-gnu:
Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a very recent regression (as it doesn't seem to reproduce
with the latest build from Compiler Explorer). 


[532] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240201 (experimental) (GCC) 
[533] % 
[533] % gcctk -O1 small.c
during GIMPLE pass: cunroll
small.c: In function ‘main’:
small.c:6:5: internal compiler error: Segmentation fault
6 | int main() {
  | ^~~~
0x1161623 crash_signal
../../gcc-trunk/gcc/toplev.cc:317
0x7f2d02c7308f ???
   
/build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xda0c28 extract_ops_from_tree(tree_node*, tree_code*, tree_node**,
tree_node**, tree_node**)
../../gcc-trunk/gcc/gimple-expr.cc:530
0xd980e0 gimple_build_assign(tree_node*, tree_node*)
../../gcc-trunk/gcc/gimple.cc:454
0x137c91c eliminate_dom_walker::eliminate_cleanup(bool)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:7494
0x13917db do_rpo_vn_1
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8720
0x13923b3 do_rpo_vn(function*, edge_def*, bitmap_head*, bool, bool, bool,
vn_lookup_kind)
../../gcc-trunk/gcc/tree-ssa-sccvn.cc:8749
0x12df179 tree_unroll_loops_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1554
0x12df2b3 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1673
0x12df2b3 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1663
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[534] % 
[534] % cat small.c
int printf(const char *, ...);
struct a {
  int b;
} n;
int a, c, d, e, f = 1, g, h, j = 1, k, l, m, o;
int main() {
  struct a p;
  int i;
  p.b = 1;
  if (!j)
goto q;
  p.b = i = 0;
  for (; i < 1; i++)
if (k)
  while (m)
  r:
  q:
if (p.b)
  g = 1;
  while (1) {
i = 0;
for (; i < 5; i++)
  ;
if (l) {
  while (h)
;
  if (o) {
d = 0;
for (; d < 8; d++)
  ;
  }
}
for (; e; e--)
  while (a)
p = n;
if (c)
  goto r;
printf("0");
if (f)
  break;
  }
  return 0;
}

[Bug tree-optimization/112859] [12/13/14 Regression] wrong code at -O3 on x86_64-linux-gnu

2023-12-05 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112859

--- Comment #2 from Zhendong Su  ---
> Thanks for these testcases btw.

Happy to be of help, Richard. 

And thanks to you folks for the incredible work and dedication!

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

2023-12-05 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112859

Bug ID: 112859
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a regression from 11.*, and affects 12.* and later.

Compiler Explorer: https://godbolt.org/z/aa8vrex9c

[555] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231205 (experimental) (GCC) 
[556] % 
[556] % gcctk -O2 small.c; ./a.out
[557] % 
[557] % gcctk -O3 small.c
[558] % ./a.out
Aborted
[559] % 
[559] % cat small.c
struct a {
  char b;
  int c;
} f, *i = 
static struct a e[4];
int *d, **g = 
static int h, j;
int main() {
  for (; h < 1; h++) {
struct a k = {1, 1};
for (j = 0; j < 2; j++) {
  *i = e[h];
  e[h] = k;
}
*g = 0;
  }
  if (f.c != 1)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/112827] [14 Regression] ICE on valid code at -O1 on x86_64-linux-gnu: Segmentation fault

2023-12-03 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112827

--- Comment #2 from Zhendong Su  ---
Another test that reproduces at -O1 and above.

[520] % gcctk -O3 small.c
during GIMPLE pass: sccp
small.c: In function ‘main’:
small.c:4:5: internal compiler error: Segmentation fault
4 | int main() {
  | ^~~~
0x105e613 crash_signal
../../gcc-trunk/gcc/toplev.cc:316
0x1149882 gimple_bb(gimple const*)
../../gcc-trunk/gcc/gimple.h:1908
0x1149882 instantiate_scev_name
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2263
0x1149882 instantiate_scev_r
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2637
0x114977d instantiate_scev_poly
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2410
0x114977d instantiate_scev_r
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2642
0x114a1de instantiate_scev(edge_def*, loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2719
0x12027c5 instantiate_parameters(loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.h:64
0x12027c5 idx_infer_loop_bounds
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:4154
0x1217343 for_each_index(tree_node**, bool (*)(tree_node*, tree_node**, void*),
void*)
../../gcc-trunk/gcc/tree-ssa-loop.cc:571
0x11ffa7d infer_loop_bounds_from_ref
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:4230
0x11ffa7d infer_loop_bounds_from_array
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:4251
0x11ffa7d infer_loop_bounds_from_undefined
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:4408
0x11ffa7d estimate_numbers_of_iterations(loop*)
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:4866
0x1201caf loop_exits_before_overflow
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:5253
0x1201caf scev_probably_wraps_p(tree_node*, tree_node*, tree_node*, gimple*,
loop*, bool)
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:5505
0x1201caf scev_probably_wraps_p(tree_node*, tree_node*, tree_node*, gimple*,
loop*, bool)
../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:5463
0x2033067 convert_affine_scev(loop*, tree_node*, tree_node**, tree_node**,
gimple*, bool, tree_node*)
../../gcc-trunk/gcc/tree-chrec.cc:1425
0x2032abe chrec_convert_1
../../gcc-trunk/gcc/tree-chrec.cc:1483
0x114a923 scev_dfs::follow_ssa_edge_expr(gimple*, tree_node*, tree_node**, int)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1238
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[521] % 
[521] % cat small.c
short a, b[1], f;
char c, g;
int d, e;
int main() {
  for (; f; f++) {
for (d = 0; d < 2; d++)
  ;
if (a)
  for (g = 0; g < 2; g++)
for (c = 0; c < 2; c += b[d+g])
  ;
for (; e; e++)
  ;
  }
  return 0;
}

[Bug tree-optimization/112827] New: ICE on valid code at -O1 on x86_64-linux-gnu: Segmentation fault

2023-12-02 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112827

Bug ID: 112827
   Summary: ICE on valid code at -O1 on x86_64-linux-gnu:
Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it does not reproduce with 13.2. 

Compiler Explorer: https://godbolt.org/z/4EhdjPE6o

[507] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231202 (experimental) (GCC) 
[508] % 
[508] % gcctk -O1 small.c
during GIMPLE pass: sccp
small.c: In function ‘main’:
small.c:2:5: internal compiler error: Segmentation fault
2 | int main() {
  | ^~~~
0x105e273 crash_signal
../../gcc-trunk/gcc/toplev.cc:316
0x1149492 gimple_bb(gimple const*)
../../gcc-trunk/gcc/gimple.h:1908
0x1149492 instantiate_scev_name
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2263
0x1149492 instantiate_scev_r
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2637
0x1149dee instantiate_scev(edge_def*, loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2719
0x114bae9 instantiate_parameters(loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.h:64
0x114bae9 simplify_peeled_chrec
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1344
0x11488a6 analyze_evolution_in_loop
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1455
0x11488a6 interpret_loop_phi
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1587
0x11488a6 analyze_scalar_evolution_1
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1975
0x114849a analyze_scalar_evolution_1
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1958
0x1148e24 analyze_scalar_evolution(loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2039
0x11483ee interpret_condition_phi
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1611
0x11483ee analyze_scalar_evolution_1
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1977
0x1148e24 analyze_scalar_evolution(loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2039
0x114abd2 interpret_rhs_expr
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1641
0x1148579 interpret_gimple_assign
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1919
0x1148579 analyze_scalar_evolution_1
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1970
0x1148e24 analyze_scalar_evolution(loop*, tree_node*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:2039
0x114abd2 interpret_rhs_expr
../../gcc-trunk/gcc/tree-scalar-evolution.cc:1641
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[509] % 
[509] % cat small.c
int a, b, c, d, e;
int main() {
  for (; c; c++) {
for (a = 0; a < 2; a++)
  ;
for (; b; b++) {
  e = d;
  d = a;
}
  }
  return 0;
}

[Bug tree-optimization/112636] New: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with "-ftree-vectorize": in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1069

2023-11-20 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112636

Bug ID: 112636
   Summary: ICE on valid code at -O1 (but not at -O{0,s,2,3}) with
"-ftree-vectorize": in adjust_loop_info_after_peeling,
at tree-ssa-loop-ivcanon.cc:1069
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it does not seem to reproduce with
13.2.

Compiler Explorer: https://godbolt.org/z/WYsasWefh

[526] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231119 (experimental) (GCC) 
[527] % 
[527] % gcctk -O1 small.c; ./a.out
[528] % 
[528] % gcctk -O1 -ftree-vectorize small.c
during GIMPLE pass: ch_vect
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in adjust_loop_info_after_peeling, at
tree-ssa-loop-ivcanon.cc:1069
3 | int main() {
  | ^~~~
0x87ac95 adjust_loop_info_after_peeling(loop*, int, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1069
0x129b514 copy_headers
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1108
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[529] % 
[529] % cat small.c
int a[1], b;
unsigned c;
int main() {
  while (b) {
if (a[c])
  break;
c--;
  }
  return 0;
}

[Bug tree-optimization/112616] New: wrong code at -O{s,2,3} on x86_64-linux-gnu

2023-11-18 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112616

Bug ID: 112616
   Summary: wrong code at -O{s,2,3} 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 9.*, and affects 10.* and later.

Compiler Explorer: https://godbolt.org/z/GxdzdqTjd


[510] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231118 (experimental) (GCC) 
[511] % 
[511] % gcctk -O1 small.c; ./a.out
[512] % 
[512] % gcctk -O3 small.c
[513] % ./a.out
Segmentation fault
[514] % 
[514] % cat small.c
unsigned a;
int b, d, e, f = 2, g, h = 1, *i = 
volatile int c = 1;
static int *o() {
  long m = ~a;
  int j = f / b, k = f - 1, n = m << -1 / ~g / k;
  if (j && n)
c;
  return 
}
static long p() {
  int *q = 0, **r = 
  if (c) {
*i = h;
*r = o();
  }
  return *q;
}
int main() {
  p();
  int *l = 0;
  if (d)
c = *l;
  return 0;
}

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

2023-11-17 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112585

Bug ID: 112585
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it does not reproduce with 13.2. 

Compiler Explorer: https://godbolt.org/z/ec94Yo6To


[563] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231117 (experimental) (GCC) 
[564] % 
[564] % gcctk -O2 small.c; ./a.out
[565] % 
[565] % gcctk -O3 small.c
[566] % ./a.out
Aborted
[567] % 
[567] % cat small.c
static int a[10], b;
char c, *d = , e;
int main() {
  int f = 0;
  for (; f < 9; f++) {
a[f] = 1;
a[f + 1] = e;
for (b = 0; b < 8; b++)
  *d = 0;
  }
  if (a[2] != 1)
__builtin_abort();
  return 0;
}

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

2023-11-16 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112581

Bug ID: 112581
   Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu
(generated code hangs)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This should be a very recent regression as it does not seem to reproduce with
the latest build on Compiler Explorer. 


[530] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231117 (experimental) (GCC) 
[531] % 
[531] % gcctk -Os small.c
[532] % ./a.out
[533] % 
[533] % gcctk -O2 small.c
[534] % timeout -s 9 5 ./a.out
Killed
[535] % 
[535] % cat small.c
int a = -1, b = 2501896061, c, d, e, f = 3, g;
int main() {
  unsigned h;
  int i;
  d = 0;
  for (; d < 1; d++) {
int j = ~-((6UL ^ a) / b);
if (b)
L:
  if (!f)
continue;
if (c)
  i = 1;
if (j) {
  i = 0;
  while (e)
;
}
g = -1 % b;
h = ~(b || h);
f = g || 0;
a = a || 0;
if (!a)
  h = 0;
while (h > 4294967294)
  if (i)
break;
if (c)
  goto L;
  }
  return 0;
}

[Bug tree-optimization/112333] New: ICE on valid code at -O2 and -O3: Segmentation fault

2023-11-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112333

Bug ID: 112333
   Summary: ICE on valid code at -O2 and -O3: Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/z8fo6PvPh 

With my local build, -g is needed to reproduce the ICE. 

[512] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231101 (experimental) (GCC) 
[513] % 
[513] % gcctk -O3 -g small.c
during GIMPLE pass: ccp
small.c: In function ‘main’:
small.c:3:5: internal compiler error: Segmentation fault
3 | int main() {
  | ^~~~
0x111dc93 crash_signal
../../gcc-trunk/gcc/toplev.cc:315
0x7f658ef6c08f ???
   
/build/glibc-BHL3KM/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xd70a7b gsi_for_stmt(gimple*)
../../gcc-trunk/gcc/gimple-iterator.cc:615
0x13a2e72 insert_debug_temp_for_var_def(gimple_stmt_iterator*, tree_node*)
../../gcc-trunk/gcc/tree-ssa.cc:471
0x13a329a insert_debug_temps_for_defs(gimple_stmt_iterator*)
../../gcc-trunk/gcc/tree-ssa.cc:506
0xd707e4 gsi_remove(gimple_stmt_iterator*, bool)
../../gcc-trunk/gcc/gimple-iterator.cc:567
0x12624c2 simple_dce_from_worklist(bitmap_head*, bitmap_head*)
../../gcc-trunk/gcc/tree-ssa-dce.cc:2206
0x1314c1a substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
../../gcc-trunk/gcc/tree-ssa-propagate.cc:1001
0x1242db8 ccp_finalize
../../gcc-trunk/gcc/tree-ssa-ccp.cc:1031
0x1243468 do_ssa_ccp
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2980
0x1243468 execute
../../gcc-trunk/gcc/tree-ssa-ccp.cc:3025
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[514] % 
[514] % cat small.c
int printf(const char *, ...);
int a, b, c, d, e;
int main() {
  long g;
  int h = a, i;
  if (e)
goto j;
  i = 0;
  for (; i < 1; i++) {
int k = d | c, l = ~a;
if (k) {
m:
  e = 0;
j:
  b = l;
  if (c)
goto m;
}
  }
  if (a) {
while (a > 1)
  a--;
g = a;
printf("%d", h);
  }
  while (a)
;
  return 0;
}

[Bug tree-optimization/111043] [14 regression] ICE in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1068

2023-11-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111043

--- Comment #9 from Zhendong Su  ---
Another at -O2 and -O3:

[545] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231101 (experimental) (GCC) 
[546] % 
[546] % gcctk -O2 small.c
during GIMPLE pass: ch_vect
small.c: In function ‘main’:
small.c:21:5: internal compiler error: in adjust_loop_info_after_peeling, at
tree-ssa-loop-ivcanon.cc:1069
   21 | int main() {
  | ^~~~
0x8736bd adjust_loop_info_after_peeling(loop*, int, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1069
0x1287a14 copy_headers
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1108
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[547] % 
[547] % cat small.c
int a, *b, c, *d, e, f;
static void g() {
  int h;
while (1)
  while (1) {
int *i = 0;
h = 0;
while (c)
  *d = 1;
if (e)
  break;
if ((h ^ f) > f)
  for (; e < 1; e++)
;
for (a = 0; a < 1; a++)
  if (*i)
break;
b = 
  }
}
int main() {
  if (a)
g();
  return 0;
}

[Bug tree-optimization/112303] [14 Regression] ICE on valid code at -O3 on x86_64-linux-gnu: verify_flow_info failed since r14-3459-g0c78240fd7d519

2023-10-31 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112303

--- Comment #5 from Zhendong Su  ---
(In reply to Sam James from comment #3)
> (In reply to Zhendong Su from comment #0)
> > This appears to be a recent regression.
> > 
> 
> Out of interest, when you say this, do you have a rough range in mind? It'd
> make bisecting easier. Or do you just mean you surely would've hit it by now
> with your testing if it had been there a while?

By "This appears to be a recent regression", I typically mean, according to
Compiler Explorer, the bug is only reproduced with its current trunk build.

[Bug tree-optimization/112303] ICE on valid code at -O3 on x86_64-linux-gnu: verify_flow_info failed

2023-10-30 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112303

--- Comment #1 from Zhendong Su  ---
Also see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111328

[Bug tree-optimization/112303] New: ICE on valid code at -O3 on x86_64-linux-gnu: verify_flow_info failed

2023-10-30 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112303

Bug ID: 112303
   Summary: ICE on valid code at -O3 on x86_64-linux-gnu:
verify_flow_info failed
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/9h7K8eqs8

[578] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231030 (experimental) (GCC)
[579] %
[579] % gcctk -O2 -c small.c
[580] %
[580] % gcctk -O3 -c small.c
small.c: In function ‘j’:
small.c:3:6: error: count of bb 228 not initialized
3 | int *j() {
  |  ^
during GIMPLE pass: cunroll
small.c:3:6: internal compiler error: verify_flow_info failed
0xbafcaf verify_flow_info()
../../gcc-trunk/gcc/cfghooks.cc:287
0x11718ff checking_verify_flow_info()
../../gcc-trunk/gcc/cfghooks.h:214
0x11718ff cleanup_tree_cfg_noloop
../../gcc-trunk/gcc/tree-cfgcleanup.cc:1154
0x11718ff cleanup_tree_cfg(unsigned int)
../../gcc-trunk/gcc/tree-cfgcleanup.cc:1205
0x1295dbd tree_unroll_loops_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1565
0x1295ed3 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1673
0x1295ed3 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1663
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[581] %
[581] % cat small.c
int a, b, d, e, f, **g, h;
char c;
int *j() {
  for (int i = 0; i < 3; i++) {
for (h = 0; h < 2; h++)
  ;
if (!b)
  break;
  }
  while (f)
while (e) {
  c = 0;
  while (d)
while (a)
  *g = j();
}
  return 0;
}

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

2023-10-29 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112282

Bug ID: 112282
   Summary: wrong code (generated 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

The code is very tough to reduce, but it appears to be a recent regression. 

Although the reduced code is still quite hairy, it does seem valid.

Compiler Explorer: https://godbolt.org/z/TxGdP87EW


[621] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231029 (experimental) (GCC) 
[622] % 
[622] % gcctk -O2 small.c; ./a.out
[623] % 
[623] % gcctk -O3 small.c
[624] % timeout -s 9 10 ./a.out
Killed
[625] % cat small.c
int printf(const char *, ...);
void __assert_fail();
int a, g, h, i, v, w = 2, x, y, ab, ac, ad, ae, af, ag;
static int f, j, m, n, p, r, u, aa;
struct b {
  int c : 20;
  int d : 20;
  int e : 10;
};
static struct b l, o, q = {3, 3, 5};
int s(int z) {
  struct b ah;
  int ai = 1, aj[7] = {1, 1, 1, 1, 1, 1, 1};
ak:
  for (u = -22; u < 2; ++u) {
struct b al[8] = {{2, 7, 9}, {8, 7, 1}, {2, 7, 9}, {8, 7, 1}, {2, 7, 9},
{8, 7, 1}, {2, 7, 9}};
y = z = 0;
for (; z < 2; z++) {
  int am[18], k;
  ab = ac = 0;
  for (; ac < 1; ac++)
for (k = 0; k < 9; k++)
  am[k] = 0;
  n = 0;
  while (1) {
v = u < 0 || a;
h = z < ~u && 4 & q.c;
if ((aa <= l.c) > q.d && p)
  return o.c;
if (w)
  break;
return q.e;
  }
  a = j;
}
  }
  for (x = 0; x < 2; x++) {
struct b an = {1, 8, 4};
int ao[28] = {5, 0, 0, 9, 0, 3, 0, 5, 0, 0, 9, 0, 3, 0, 5, 0, 0, 9, 0, 3,
0, 5, 0, 0, 9, 0, 3, 0};
if (q.e) {
  int ap = ai || l.c + q.c, aq = q.d, ar = p & f;
  q.d = q.d || ar || ap;
  p = 0;
  if (!j && ai)
goto as;
  if (q.d) {
printf("", l);
q.d = f >> j;
  }
  p = l.c = aq;
  an = q;
} else {
  int at[12][1] = {{9}, {9}, {5}, {9}, {9}, {5}, {9}, {9}, {5}, {9}, {9},
{5}};
  struct b au;
  if (o.c)
aa = ah.e;
  if (an.d)
ah.e = (j & (aa * m)) ^ au.d;
  o.c = m + aa;
  int av = o.c || 0, aw = ai || q.c & l.c, ax = n;
  if (q.e < ai)
q = an;
  if (r)
break;
  ai = aw - av;
  an.e = 0;
  if (ai) {
an.e = l.c || 0;
f = q.c;
ah.e = l.c % q.d;
q.c = au.e;
if ((q.d && q.c) || ah.e)
  __assert_fail();
q.c = 0;
if (au.d > m || ah.e)
  w = au.c | (n & ah.c);
  as:
ae = af = ah.c;
int ay = au.d & q.e & au.c || o.c, az = 0 || o.c, ba = m & ah.d;
if (n)
  au.c = au.e = (q.e || ah.d) ^ (o.c + (az / au.e));
n = au.c || au.e;
if (ba) {
  printf("", ax);
  x = q.e | m;
  continue;
}
m = ay;
n = printf("", au);
  }
  if (ah.d)
o.c = l.c & o.c & q.c;
  if (q.d)
__assert_fail();
  printf("", an);
  printf("", q);
  printf("", au);
  if (ah.e)
while (u++) {
  struct b al[7] = {{7, 9, 8}, {7, 1, 2}, {7, 9, 8}, {7, 1, 2}, {7, 9,
8}, {7, 1, 2}, {7, 9, 0}};
  if (an.d) {
int d[8] = {0, 1, 0, 1, 0, 1, 0, 1};
if (ad)
  goto ak;
while (ag)
  g = an.d = i = m;
f = j;
  }
  n++;
}
  f = q.d;
}
if (l.c && m) {
  int d[7] = {1, 0, 1, 0, 1, 0, 1};
  if (x)
h = an.d;
  else
g = 0;
}
  }
  int bb = (q.d ^ ah.c) | aa | (q.e & q.c) | (f & ah.d);
  if (bb)
return x;
  return 0;
}
int main() {
  j = 1;
  s(0);
  return 0;
}

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

2023-10-29 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112281

Bug ID: 112281
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This is a regression from 11.*, and affects 12.* and later. It should be
distinct from those couple of open issues with loop splitting. 

Compiler Explorer: https://godbolt.org/z/1anT983Td

[573] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231029 (experimental) (GCC) 
[574] % 
[574] % gcctk -O2 small.c; ./a.out
[575] % 
[575] % gcctk -O3 small.c; ./a.out
Aborted
[576] % gcctk -O3 -fno-split-loops small.c; ./a.out
Aborted
[577] % 
[577] % cat small.c
struct {
  int : 8;
  int a;
} b, d[4] = {{0}, {0}, {0}, {5}};
int c, e;
int main() {
  for (c = 2; c; c--)
for (e = 0; e < 2; e++) {
  d[c] = b = d[c + 1];
  d[c + 1].a = 0;
}
  if (b.a != 0)
__builtin_abort();
  return 0;
}

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

2023-10-28 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112113

Bug ID: 112113
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/vaY9GEnrz


[549] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231028 (experimental) (GCC) 
[550] % 
[550] % gcctk -O2 small.c; ./a.out
[551] % 
[551] % gcctk -O3 small.c
small.c: In function ‘main’:
small.c:3:29: warning: iteration 1 invokes undefined behavior
[-Waggressive-loop-optimizations]
3 |   for (int b = 0; b < 33; b += 3) {
  |   ~~^~~~
small.c:3:21: note: within this loop
3 |   for (int b = 0; b < 33; b += 3) {
  |   ~~^~~~
[552] % ./a.out
Aborted
[553] % 
[553] % cat small.c
volatile int a;
int main() {
  for (int b = 0; b < 33; b += 3) {
if (b > 31)
  a++;
  }
  if (a != 0)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs)

2023-10-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916

Bug ID: 111916
   Summary: wrong code at -O1 and above on x86_64-linux-gnu (the
generated code hangs)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/aEEKbdY6E

[563] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231022 (experimental) (GCC) 
[564] % 
[564] % gcctk -O0 small.c; ./a.out
[565] % 
[565] % gcctk -O1 small.c
[566] % timeout -s 9 5 ./a.out
Killed
[567] % 
[567] % cat small.c
#pragma pack(1)
struct A {
  int b : 4;
  int c : 11;
  int d : 2;
  int e : 5;
} f;
int main() {
  struct A g = {1, 1, 1, 1};
  while (!g.b)
f = g;
  return 0;
}

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

2023-10-16 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111838

Bug ID: 111838
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/Mx76x5h5K


[614] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231016 (experimental) (GCC) 
[615] % 
[615] % gcctk -O2 small.c; ./a.out
[616] % 
[616] % gcctk -O3 small.c; ./a.out
small.c: In function ‘main’:
small.c:6:17: warning: iteration 4 invokes undefined behavior
[-Waggressive-loop-optimizations]
6 |   if (e ? a % e : 0)
  |   ~~^~~
small.c:5:26: note: within this loop
5 | for (char e = -17; e < 1; e += 5) {
  |~~^~~
Floating point exception
[617] % 
[617] % cat small.c
int a, b, c;
volatile char d;
int main() {
  for (; b < 1; b++)
for (char e = -17; e < 1; e += 5) {
  if (e ? a % e : 0)
d;
  for (c = 0; c < 1; c++)
;
}
  return 0;
}

[Bug tree-optimization/111823] New: ICE on valid code at -O1 and above on x86_64-linux-gnu: in verify_sra_access_forest, at tree-sra.cc:2414

2023-10-15 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111823

Bug ID: 111823
   Summary: ICE on valid code at -O1 and above on
x86_64-linux-gnu: in verify_sra_access_forest, at
tree-sra.cc:2414
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/jMsxnbTcK

[514] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231015 (experimental) (GCC) 
[515] % 
[515] % gcctk -O1 small.c
during GIMPLE pass: esra
small.c: In function ‘main’:
small.c:9:1: internal compiler error: in verify_sra_access_forest, at
tree-sra.cc:2414
9 | }
  | ^
0x85c78c verify_sra_access_forest(access*)
../../gcc-trunk/gcc/tree-sra.cc:2414
0x1209a92 verify_all_sra_access_forests()
../../gcc-trunk/gcc/tree-sra.cc:2465
0x120d6b4 analyze_all_variable_accesses
../../gcc-trunk/gcc/tree-sra.cc:3534
0x120dc01 perform_intra_sra
../../gcc-trunk/gcc/tree-sra.cc:4726
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[516] % 
[516] % cat small.c
static struct A {
  int x : 4;
} a;
static int b;
int main() {
  struct A t[2];
  t[0] = b ? t[1] : a;
  return (b ? t[1].x : 0) && 1;
}

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

2023-10-13 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111727

--- Comment #2 from Zhendong Su  ---
Another similar/related test:

[553] % gcctk -O2 small.c; ./a.out
[554] % 
[554] % gcctk -O3 small.c
[555] % ./a.out
Aborted
[556] % cat small.c
int a, b;
int main() {
  for (; a < 4; a += 2)
if (a > 2)
  while (b++);
;
  if (a != 4)
__builtin_abort();
  return 0;
}

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

2023-10-13 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111792

Bug ID: 111792
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

compiler Explorer: https://godbolt.org/z/7vfzPYTrn

[537] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231013 (experimental) (GCC) 
[538] % 
[538] % gcctk -O2 small.c; ./a.out
[539] % 
[539] % gcctk -O3 small.c
[540] % ./a.out
Aborted
[541] % cat small.c
int c, d, h, i, j, l, *n = 
short e, f, g, *k, m;
long o;
short p(short p1, int q) { return q >= 32 || p1 > 5 >> q ? 1 : p1 << q; }
long u(unsigned p1) {
  int r = 50, s, *t = 
 L:
  m && (*k = 0);
  for (d = 1; d; d--)
for (s = 0; s < 3; s++) {
  *n = i ^ p1;
  *t = p1 > (unsigned)p((unsigned)(o = 4073709551615) >= p1 && 5, r);
  if (f)
goto L;
}
  for (; e < 1;)
return j;
  int *b[2] = {, };
  for (; l; l--) {
long a[1];
for (r = 0; r < 1; r++) {
  h = a[0];
  if (g)
goto L;
}
  }
  return 0;
}
int main() {
  u(6);
  if (c != 1)
__builtin_abort();
  return 0;
}

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

2023-10-08 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111727

Bug ID: 111727
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/xherWE8x6

It might be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111652.

[508] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231008 (experimental) (GCC) 
[509] % 
[509] % gcctk -O2 small.c; ./a.out
[510] % 
[510] % gcctk -O3 small.c
[511] % ./a.out
Aborted
[512] % cat small.c
int a, b, c;
int main() {
  for (; a < 2; a += 2) {
for (b = 0; b < 1; b++)
  if (a < 1)
c = 0;
for (; c < 1; c++)
  ;
}
  if (a != 2)
__builtin_abort();
  return 0;
}

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

2023-10-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111652

Bug ID: 111652
   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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/89h8W1Pvs

[505] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231001 (experimental) (GCC) 
[506] % 
[506] % gcctk -O2 small.c; ./a.out
[507] % 
[507] % gcctk -O3 small.c
[508] % ./a.out
Aborted
[509] % 
[509] % cat small.c
volatile int a;
int b;
int main() {
  for (; b < 5; b += 3) {
b && a;
if (b < 4)
  a--;
  }
  if (b != 6)
__builtin_abort();
  return 0;
}

[Bug c++/111482] [14 Regression] ice in lower_bound with -O3

2023-09-19 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111482

Zhendong Su  changed:

   What|Removed |Added

 CC||zhendong.su at inf dot ethz.ch

--- Comment #3 from Zhendong Su  ---
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111355

[Bug tree-optimization/111355] [14 Regression] ICE on valid code at -O1 and above: in lower_bound, at value-range.h:1078

2023-09-19 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111355

--- Comment #2 from Zhendong Su  ---
It seems that the fix for PR 111303 did not fix this ICE.

[511] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230919 (experimental) (GCC) 
[512] % 
[512] % gcctk -O1 small.c 
small.c: In function ‘main’:
small.c:3:23: warning: division by zero [-Wdiv-by-zero]
3 |   return b ? 1 << --b / 0 : 0;
  |   ^
during GIMPLE pass: ccp
small.c:4:1: internal compiler error: in lower_bound, at value-range.h:1078
4 | }
  | ^
0x9293e1 irange::lower_bound(unsigned int) const
../../gcc-trunk/gcc/value-range.h:1078
0x9293e1 irange::lower_bound(unsigned int) const
../../gcc-trunk/gcc/value-range.h:1076
0x9293e1 gimple_simplify_TRUNC_DIV_EXPR(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*)
/local/suz-local/software/gccbuild/objdir/gcc/gimple-match-4.cc:8423
0x1646816 gimple_resimplify2
../../gcc-trunk/gcc/gimple-match-exports.cc:1001
0x16472b0 gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node* (*)(tree_node*))
../../gcc-trunk/gcc/gimple-match-exports.cc:868
0xca6c5c gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*),
tree_node* (*)(tree_node*))
../../gcc-trunk/gcc/gimple-fold.cc:7545
0x11316f2 ccp_fold
../../gcc-trunk/gcc/tree-ssa-ccp.cc:1288
0x11316f2 evaluate_stmt
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2225
0x11330c5 visit_assignment
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2859
0x11e705a ssa_propagation_engine::simulate_stmt(gimple*)
../../gcc-trunk/gcc/tree-ssa-propagate.cc:221
0x11e736a ssa_propagation_engine::simulate_block(basic_block_def*)
../../gcc-trunk/gcc/tree-ssa-propagate.cc:328
0x11e7773 ssa_propagation_engine::ssa_propagate()
../../gcc-trunk/gcc/tree-ssa-propagate.cc:478
0x1128f00 do_ssa_ccp
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2978
0x1128f00 execute
../../gcc-trunk/gcc/tree-ssa-ccp.cc:3024
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[513] % 
[513] % cat small.c 
int main() {
  unsigned b;
  return b ? 1 << --b / 0 : 0;
}

[Bug tree-optimization/111442] New: ICE on valid code at -O{s,2,3}: Segmentation fault signal terminated program cc1

2023-09-17 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111442

Bug ID: 111442
   Summary: ICE on valid code at -O{s,2,3}: Segmentation fault
signal terminated program cc1
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/TY6sWMvcv

[542] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230917 (experimental) (GCC) 
[543] % 
[543] % gcctk -Os small.c
small.c: In function ‘main’:
small.c:5:15: warning: division by zero [-Wdiv-by-zero]
5 | e = a ? 0 % 0 : 0;
  |   ^
gcctk: internal compiler error: Segmentation fault signal terminated program
cc1
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See  for instructions.
[544] % 
[544] % cat small.c
int *a, b;
int main() {
  int d = 1, e;
  if (d)
e = a ? 0 % 0 : 0;
  if (d)
a = 
  d = -1;
  b = d & e;
  b = 2 * e ^ 1;
  return 0;
}

[Bug tree-optimization/111387] New: ICE on valid code at -O2 and -O3: verify_ssa failed

2023-09-12 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111387

Bug ID: 111387
   Summary: ICE on valid code at -O2 and -O3: verify_ssa failed
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/9v9T5bfz9

[517] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230912 (experimental) (GCC) 
[518] % 
[518] % gcctk -O2 small.c
small.c: In function ‘main’:
small.c:6:5: error: definition in block 5 does not dominate use in block 2
6 | int main() {
  | ^~~~
for SSA_NAME: l_23 in statement:
_4 = {0, l_23};
during GIMPLE pass: slp
small.c:6:5: internal compiler error: verify_ssa failed
0x126622d verify_ssa(bool, bool)
../../gcc-trunk/gcc/tree-ssa.cc:1203
0xee7085 execute_function_todo
../../gcc-trunk/gcc/passes.cc:2095
0xee74db execute_todo
../../gcc-trunk/gcc/passes.cc:2142
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[519] % 
[519] % cat small.c
struct {
  unsigned a;
  unsigned b;
} c;
int d, e, f, g, h;
int main() {
  if (c.b && g && g > 7)
goto i;
 j:
  if (c.a) {
int k = 0;
unsigned l = c.b;
if (0) {
m:
  k = l = c.b;
}
c.a = k;
c.b = l;
  }
  if (0) {
  i:
goto m;
  }
  if (d)
goto j;
  for (f = 5; f; f--)
if (h)
  e = 0;
  return 0;
}

[Bug tree-optimization/111355] New: ICE on valid code at -O1 and above: in lower_bound, at value-range.h:1078

2023-09-09 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111355

Bug ID: 111355
   Summary: ICE on valid code at -O1 and above: in lower_bound, at
value-range.h:1078
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/rPvxdPsE4

[519] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230909 (experimental) (GCC) 
[520] % 
[520] % gcctk -O1 -w small.c
during GIMPLE pass: ccp
small.c: In function ‘main’:
small.c:4:1: internal compiler error: in lower_bound, at value-range.h:1078
4 | }
  | ^
0xd3617e irange::lower_bound(unsigned int) const
../../gcc-trunk/gcc/value-range.h:1078
0xd3617e irange::lower_bound(unsigned int) const
../../gcc-trunk/gcc/value-range.h:1076
0x161e375 gimple_simplify_TRUNC_DIV_EXPR(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*)
/local/suz-local/software/gccbuild/objdir/gcc/gimple-match-7.cc:8473
0x173a4c6 gimple_resimplify2
../../gcc-trunk/gcc/gimple-match-exports.cc:1001
0x173af60 gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node* (*)(tree_node*))
../../gcc-trunk/gcc/gimple-match-exports.cc:868
0xca44fc gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*),
tree_node* (*)(tree_node*))
../../gcc-trunk/gcc/gimple-fold.cc:7545
0x112da22 ccp_fold
../../gcc-trunk/gcc/tree-ssa-ccp.cc:1288
0x112da22 evaluate_stmt
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2225
0x112f3f5 visit_assignment
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2859
0x11e2f1a ssa_propagation_engine::simulate_stmt(gimple*)
../../gcc-trunk/gcc/tree-ssa-propagate.cc:221
0x11e322a ssa_propagation_engine::simulate_block(basic_block_def*)
../../gcc-trunk/gcc/tree-ssa-propagate.cc:328
0x11e3633 ssa_propagation_engine::ssa_propagate()
../../gcc-trunk/gcc/tree-ssa-propagate.cc:478
0x1125230 do_ssa_ccp
../../gcc-trunk/gcc/tree-ssa-ccp.cc:2978
0x1125230 execute
../../gcc-trunk/gcc/tree-ssa-ccp.cc:3024
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[521] % 
[521] % cat small.c
int main() {
  unsigned b;
  return b ? 1 << --b / 0 : 0;
}

[Bug tree-optimization/111043] [14 regression] ICE in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1068

2023-09-03 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111043

Zhendong Su  changed:

   What|Removed |Added

 CC||zhendong.su at inf dot ethz.ch

--- Comment #6 from Zhendong Su  ---
Another reproducer at -O3.

Compiler Explorer: https://godbolt.org/z/GYWG1G47K

[576] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230902 (experimental) (GCC) 
[577] % 
[577] % gcctk -O3 small.c
during GIMPLE pass: ch_vect
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in adjust_loop_info_after_peeling, at
tree-ssa-loop-ivcanon.cc:1068
3 | int main() {
  | ^~~~
0x8299be adjust_loop_info_after_peeling(loop*, int, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1068
0x1154a33 copy_headers
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1108
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[578] % cat small.c
int a = 1, b;
unsigned c = 2;
int main() {
  while (a >= c)
;
  while (a && b)
;
  while (!a || a >= c)
c++;
  return 0;
}

[Bug tree-optimization/110971] New: ICE on valid code at -O3 on x86_64-linux-gnu: in operator/, at sreal.cc:261

2023-08-10 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110971

Bug ID: 110971
   Summary: ICE on valid code at -O3 on x86_64-linux-gnu: in
operator/, at sreal.cc:261
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/een8566xd

[532] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230810 (experimental) (GCC)
[533] %
[533] % gcctk -O3 small.c
during GIMPLE pass: lsplit
small.c: In function ‘main’:
small.c:2:5: internal compiler error: in operator/, at sreal.cc:261
2 | int main() {
  | ^~~~
0x7e52f5 sreal::operator/(sreal const&) const
../../gcc-trunk/gcc/sreal.cc:261
0x7e52f5 sreal::operator/(sreal const&) const
../../gcc-trunk/gcc/sreal.cc:259
0x118e47b split_loop
../../gcc-trunk/gcc/tree-ssa-loop-split.cc:719
0x118ed4b tree_ssa_split_loops
../../gcc-trunk/gcc/tree-ssa-loop-split.cc:1769
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[534] %
[534] % cat small.c
int a, b, c, d;
int main() {
  for (a = 0; a < 2; a++) {
if (b > 2)
  c = 0;
if (b > a)
  d = 0;
  }
  return 0;
}

[Bug rtl-optimization/110940] New: ICE at -O3 on x86_64-linux-gnu: in apply_scale, at profile-count.h:1180

2023-08-07 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110940

Bug ID: 110940
   Summary: ICE at -O3 on x86_64-linux-gnu: in apply_scale, at
profile-count.h:1180
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/evGMc8xEW

[595] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230808 (experimental) (GCC) 
[596] % 
[596] % gcctk -O3 -c small.c
during GIMPLE pass: vect
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in apply_scale, at profile-count.h:1180
3 | int main() {
  | ^~~~
0xab66c3 profile_count::apply_scale(profile_count, profile_count) const
../../gcc-trunk/gcc/profile-count.h:1180
0x10311cf fold_loop_internal_call(gimple*, tree_node*)
../../gcc-trunk/gcc/tree-cfg.cc:7738
0x12d2ef5 execute
../../gcc-trunk/gcc/tree-vectorizer.cc:1328
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[597] % 
[597] % cat small.c
int a, b[1], c, *d = , e, f, g, h, i, j;
extern int l();
int main() {
  if (l())
for (;;)
  for (; g;)
for (; e;)
  for (; a;)
for (; f;)
  for (; h;)
for (; i;)
  for (; c;)
for (; j;)
  ;
  l();
  for (; c; c++)
b[*d] = 0;
  return 0;
}

[Bug tree-optimization/110924] New: ICE on valid code at -O{s,2,3} on x86_64-linux-gnu: verify_ssa failed

2023-08-06 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110924

Bug ID: 110924
   Summary: ICE on valid code at -O{s,2,3} on x86_64-linux-gnu:
verify_ssa failed
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/z9oPe5bnx

[608] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230805 (experimental) (GCC)
[609] %
[609] % gcctk -O2 small.c
small.c: In function ‘main’:
small.c:8:5: error: stmt with wrong VUSE
8 | int main() {
  | ^~~~
# VUSE <.MEM_11>
e.3_2 = e;
expected .MEM_12
during GIMPLE pass: sink
small.c:8:5: internal compiler error: verify_ssa failed
0x124c54d verify_ssa(bool, bool)
../../gcc-trunk/gcc/tree-ssa.cc:1203
0xed05e5 execute_function_todo
../../gcc-trunk/gcc/passes.cc:2095
0xed0a3b execute_todo
../../gcc-trunk/gcc/passes.cc:2142
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[610] %
[610] % cat small.c
int a[1], b, c, d, e, f, g;
void h(int i, int j) {
  int *k = 0;
  if (*k)
h(0, 0);
  g = i && d;
}
int main() {
  if (c)
goto l;
  if (!a)
while (1) {
  f = 1;
  while (f)
h(b && main(), e);
  while (1)
;
l:;
}
  return 0;
}

[Bug tree-optimization/110769] ICE in adjust_loop_info_after_peeling, at tree-ssa-loop-ivcanon.cc:1023

2023-07-22 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110769

Zhendong Su  changed:

   What|Removed |Added

 CC||zhendong.su at inf dot ethz.ch

--- Comment #2 from Zhendong Su  ---
Another related test:

[591] % gcctk -O3 small.c
during GIMPLE pass: ch_vect
small.c: In function ‘main’:
small.c:2:5: internal compiler error: in adjust_loop_info_after_peeling, at
tree-ssa-loop-ivcanon.cc:1023
2 | int main() {
  | ^~~~
0x821ffd adjust_loop_info_after_peeling(loop*, int, bool)
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1023
0x1142471 copy_headers
../../gcc-trunk/gcc/tree-ssa-loop-ch.cc:1110
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[592] % 
[592] % cat small.c
int a, b, c, *d = 
int main() {
  while (b)
;
  a++;
  if (!c && !d)
__builtin_abort();
  while (!a || b > 0)
b++;
  return 0;
}

[Bug tree-optimization/110766] New: ICE on valid code at -O3 on x86_64-linux-gnu: in gimple_phi_arg_def_from_edge, at gimple.h:4699

2023-07-21 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110766

Bug ID: 110766
   Summary: ICE on valid code at -O3 on x86_64-linux-gnu: in
gimple_phi_arg_def_from_edge, at gimple.h:4699
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It seems to be related to the recently fixed PR 110669. 

Compiler Explorer: https://godbolt.org/z/85drx858c

[524] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230721 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[525] % 
[525] % gcctk -O3 small.c
during GIMPLE pass: sccp
small.c: In function ‘main’:
small.c:4:5: internal compiler error: in gimple_phi_arg_def_from_edge, at
gimple.h:4699
4 | int main() {
  | ^~~~
0x80fe21 gimple_phi_arg_def_from_edge(gphi const*, edge_def const*)
../../gcc-trunk/gcc/gimple.h:4699
0x811332 gimple_phi_arg_def_from_edge(gphi const*, edge_def const*)
../../gcc-trunk/gcc/tree.h:3700
0x811332 final_value_replacement_loop(loop*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:3733
0x118f795 execute
../../gcc-trunk/gcc/tree-ssa-loop.cc:411
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[526] % 
[526] % cat small.c
int a, b, c, e;
short d, f;
int g(int h) { return h > a ? h : h << a; }
int main() {
  while (e) {
b = 0;
for (; b < 3; b++)
  if (c) {
e = g(1);
f = e | d;
  }
d = 0;
  }
  return 0;
}

[Bug tree-optimization/110666] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu

2023-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110666

--- Comment #5 from Zhendong Su  ---
A couple of very likely related tests (especially #2 and #3):

*** (1) wrong code at -O2, -O3, and -Os

[539] % gcctk -O1 small.c; ./a.out
[540] % gcctk -O2 small.c
[541] % timeout -s 9 5 ./a.out
Killed
[542] % cat small.c
int a, b = -1, c, d = -1;
int main() {
  if (a)
goto L2;
 L1:
  a = 0;
 L2:
  b && c;
  c = ~c * (d ^ (0 || a) || d & b);
  if (c)
goto L1;
  return 0;
}

*** (2) wrong code at -O1 and above

[558] % gcctk -O0 small.c; ./a.out
[559] % gcctk -O1 small.c
[560] % ./a.out
Floating point exception
[561] % cat small.c
int a = 1, b, c;
void f(int d) {
  for (; c < 2; c++) {
if (!a)
  b = -1;
a = (d != 4) == d;
b = 1 % ~b;
  }
}
int main() { f(1 || b); }

*** (3) wrong code at -O1 and above

[577] % gcctk -O0 small.c; ./a.out
[578] % gcctk -O1 small.c
[579] % timeout -s 9 5 ./a.out
Killed
[580] % cat small.c
int a = 1, b, c, d;
void e(int f) {
  for (; c < 2; c++) {
if (b)
  d = c;
c = d;
b = f;
  }
}
int main() { e(((a != 2) != a) != 1); }

[Bug tree-optimization/110671] New: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: in gimple_phi_arg_def_from_edge, at gimple.h:4699

2023-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110671

Bug ID: 110671
   Summary: ICE on valid code at -O2 and -O3 on x86_64-linux-gnu:
in gimple_phi_arg_def_from_edge, at gimple.h:4699
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a very recent regression.

[631] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230714 (experimental) (GCC) 
[632] % 
[632] % gcctk -O2 -c small.c
during GIMPLE pass: sccp
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in gimple_phi_arg_def_from_edge, at
gimple.h:4699
3 | int main() {
  | ^~~~
0x80ec9d gimple_phi_arg_def_from_edge(gphi const*, edge_def const*)
../../gcc-trunk/gcc/gimple.h:4699
0x8101ae gimple_phi_arg_def_from_edge(gphi const*, edge_def const*)
../../gcc-trunk/gcc/tree.h:3700
0x8101ae final_value_replacement_loop(loop*)
../../gcc-trunk/gcc/tree-scalar-evolution.cc:3732
0x118a1a5 execute
../../gcc-trunk/gcc/tree-ssa-loop.cc:411
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[633] % 
[633] % cat small.c
extern void f();
int a;
int main() {
  int *b = , c = 1, d;
 L:
  if (a)
for (; d < 1; d++) {
  if (a)
f();
  *b |= c;
}
  c = 0;
  if (a)
goto L;
  return 0;
}

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

2023-07-14 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110666

Bug ID: 110666
   Summary: wrong code at -O1 and above 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/xG14vrs6K

[501] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230714 (experimental) (GCC) 
[502] % 
[502] % gcctk -O0 small.c; ./a.out
[503] % gcctk -O1 small.c; ./a.out
Aborted
[504] % cat small.c
int a;
int main() {
  if ((a != 2) == a)
__builtin_abort();
  return 0;
}

[Bug tree-optimization/110600] New: ICE on valid code at -O1 and above on x86_64-linux-gnu: Segmentation fault

2023-07-08 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110600

Bug ID: 110600
   Summary: ICE on valid code at -O1 and above on
x86_64-linux-gnu: Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

[546] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230708 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[547] % 
[547] % gcctk -O1 small.c
during GIMPLE pass: cunroll
small.c: In function ‘main’:
small.c:2:5: internal compiler error: Segmentation fault
2 | int main() {
  | ^~~~
0xfe4473 crash_signal
../../gcc-trunk/gcc/toplev.cc:314
0x7fa025ede51f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7fa025f1bfc2 __GI__IO_fwrite
./libio/iofwrite.c:37
0xad5839 fprintf
/usr/include/x86_64-linux-gnu/bits/stdio2.h:105
0xad5839 scale_loop_profile(loop*, profile_probability, long)
../../gcc-trunk/gcc/cfgloopmanip.cc:585
0x11469b5 try_unroll_loop_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:911
0x11469b5 canonicalize_loop_induction_variables
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1286
0x1147d82 tree_unroll_loops_completely_1
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1429
0x1147cea tree_unroll_loops_completely_1
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1382
0x1148134 tree_unroll_loops_completely
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1478
0x1148403 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1644
0x1148403 execute
../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1634
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[548] % 
[548] % cat small.c
int a(int b, int c) { return (b ^ c) < 0 ? b : b - c; }
int main() {
  for (int e = 0; e != -1; e = a(e, 1))
;
  return 0;
}

[Bug tree-optimization/110599] New: wrong code at -Os and above with "-fno-tree-forwprop -fno-tree-fre" on x86_64-linux-gnu

2023-07-08 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110599

Bug ID: 110599
   Summary: wrong code at -Os and above with "-fno-tree-forwprop
-fno-tree-fre" 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: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/jdrTeEser

[501] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230708 (experimental) (GCC) 
[502] % 
[502] % gcctk -O2 small.c; ./a.out
1
[503] % gcctk -O2 -fno-tree-forwprop -fno-tree-fre small.c; ./a.out
-1
[504] % cat small.c
int printf(const char *, ...);
int a, b;
int main() {
  b = ~b;
  a = b ^ (a && 1) || b;
  printf("%d\n", a);
  return 0;
}

[Bug middle-end/110228] [13/14 Regression] llvm-16 miscompiled due to an maybe uninitialized variable

2023-07-04 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110228

--- Comment #30 from Zhendong Su  ---
(In reply to Richard Biener from comment #29)
> I can't reproduce the original failure on trunk or with GCC 13.1, but the
> testcase from comment#16 is now fixed.  I also cannot reproduce the testcase
> from comment#21 before the fix.
> 
> Can people double-check this is now fixed, maybe also on the branch when this
> fix is cherry-picked?
> 
> Thanks.

I can still reproduce the test from comment#21 as well as PR 110491 and PR
110509.

PR 110376 doesn't reproduce for me anymore.

[Bug middle-end/110228] [13/14 Regression] llvm-16 miscompiled due to an maybe uninitialized variable

2023-07-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110228

--- Comment #21 from Zhendong Su  ---
Another very likely related reproducer.

[628] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230701 (experimental) [master r14-924-gd709841ae0f] (GCC)
[629] %
[629] % gcctk -O3 small.c
[630] % for i in $(seq 1 10); do
> echo $i
> ./a.out
> done
1
Floating point exception
2
Floating point exception
3
Floating point exception
4
Floating point exception
5
Floating point exception
6
Floating point exception
7
Floating point exception
8
Floating point exception
9
10
[631] % cat small.c
int a, b, c, d, e, f = 1, g, h;
int main () {
  int i;
  for (; g < 1; g++) {
  if (!a)
i = 1;
  for (; b < 1; b++)
  L:
;
}
  int k = -1 / f;
  while (d)
i = 0;
  c = k;
  e = ~i;
  if (e > h) {
  f = 0;
  goto L;
}
  return 0;
}

[Bug tree-optimization/110509] New: wrong code at -O3 on x86_64-linux-gnu (nondeterministic hang)

2023-06-30 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110509

Bug ID: 110509
   Summary: wrong code at -O3 on x86_64-linux-gnu
(nondeterministic hang)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/xMnq1jYeW

[521] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230701 (experimental) (GCC) 
[522] % 
[522] % gcctk -O3 small.c
[523] % for i in $(seq 1 10); do
> echo $i
> timeout -s 9 5 ./a.out
> done
1
2
3
4
Killed
5
6
7
Killed
8
Killed
9
Killed
10
Killed
[524] % 
[524] % cat small.c
int printf (const char *, ...);
int a, d = 10, b = 8, c, e, i, r, f, j;
int g (short l) {
  if (d)
return l;
}
int main () {
  int m[] = {987, 1, 47}, p, o = 2;
 L1:
  p = g (m[2] >= 8);
  while (1) {
while (p > 1)
  while (r) {
int h = m[a];
while (1)
  ;
  }
while (i < 9) {
  if (c && f) {
if (o) {
  p = 7 ^ j;
  b = o = 0;
  if (p <= 4) {
printf ("%d", j);
goto L2;
  }
}
if (j)
  goto L1;
  L2:
b > 1;
  }
  if (b)
return e;
}
  }
  return 0;
}

[Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu

2023-06-29 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110391

--- Comment #4 from Zhendong Su  ---
Another likely related reproducer that affects 9.* and later.

Compiler Explorer: https://godbolt.org/z/8vTd7rx6d

[641] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[642] % 
[642] % gcctk -O2 -fselective-scheduling2 -fno-tree-pre small.c
[643] % ./a.out
34
[644] % gcctk -O2 small.c
[645] % ./a.out
1
[646] % cat small.c
int printf(const char *, ...);
int a, b;
int main() {
  unsigned int c = 0;
  unsigned char d = 33;
  for (; a < 1; a++) {
unsigned int e = 0;
unsigned char f = 0;
if (c < 1) {
  e = f = d;
  c = b * 4;
  if (c < b)
printf("%ld", (long)d);
  if (!f)
break;
}
c = e;
d = f;
  }
  printf("%d\n", a);
  return 0;
}

[Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu

2023-06-29 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110252

--- Comment #10 from Zhendong Su  ---
Another very likely related test.

Compiler Explorer: https://godbolt.org/z/1n5nsefWx

[557] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[558] % 
[558] % gcctk -O2 small.c
[559] % ./a.out
Aborted
[560] % gcctk -O1 small.c; ./a.out
[561] % 
[561] % cat small.c
int a, b = 2, c = 2;
int main() {
  b = ~(1 % (a ^ (b - (1 && c) || c & b)));
  if (b < -1)
__builtin_abort();
  return 0;
}

[Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu

2023-06-29 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110391

--- Comment #3 from Zhendong Su  ---
Another related reproducer. 

Compiler Explorer: https://godbolt.org/z/E8GPcfPY5


[543] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[544] % 
[544] % gcctk -O2 -fselective-scheduling2 small.c
[545] % timeout -s 9 5 ./a.out
Killed
[546] % 
[546] % gcctk -O1 small.c; ./a.out
[547] % 
[547] % cat small.c
int printf(const char *, ...);
int a = -1, b = 1, *c = 
int main() {
  *c |= 1;
  if (a) {
  L:
if (a < -1)
  printf("%d", 0);
if (!b) {
  printf("%d", 1);
  goto L;
}
if (a > 0)
  goto L;
b = 0;
  }
  return 0;
}

[Bug rtl-optimization/110418] New: ICE on valid code at -O2 and -O3 with -fselective-scheduling2: Segmentation fault

2023-06-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110418

Bug ID: 110418
   Summary: ICE on valid code at -O2 and -O3 with
-fselective-scheduling2: Segmentation fault
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a long-latent issue, affecting 6.* and later. 

Compiler Explorer: https://godbolt.org/z/sG5bsxrKq

[506] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230625 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[507] % 
[507] % gcctk -O2 -fselective-scheduling2 small.c
during RTL pass: sched2
small.c: In function ‘main’:
small.c:20:1: internal compiler error: Segmentation fault
   20 | }
  | ^
0xfc7c03 crash_signal
../../gcc-trunk/gcc/toplev.cc:314
0x7fdf8a71151f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xf726a0 init_expr
../../gcc-trunk/gcc/sel-sched-ir.cc:1627
0xf726a0 copy_expr_onside(_expr*, _expr*)
../../gcc-trunk/gcc/sel-sched-ir.cc:1685
0xf80619 move_op_orig_expr_found
../../gcc-trunk/gcc/sel-sched.cc:5989
0xf856d9 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6543
0xf85c49 code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6342
0xf85c49 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6608
0xf85c49 code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6342
0xf85c49 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6608
0xf85c49 code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6342
0xf85c49 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6608
0xf85c49 code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6342
0xf85c49 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6608
0xf86279 move_op
../../gcc-trunk/gcc/sel-sched.cc:6702
0xf86279 move_exprs_to_boundary
../../gcc-trunk/gcc/sel-sched.cc:5223
0xf86279 schedule_expr_on_boundary
../../gcc-trunk/gcc/sel-sched.cc:5436
0xf887ef fill_insns
../../gcc-trunk/gcc/sel-sched.cc:5578
0xf887ef schedule_on_fences
../../gcc-trunk/gcc/sel-sched.cc:7353
0xf887ef sel_sched_region_2
../../gcc-trunk/gcc/sel-sched.cc:7491
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[508] % 
[508] % cat small.c
int printf (const char *, ...);
volatile int a, c, e;
int b = 1, d, f = 1;
int main ()
{
  int h, i = b - c, k;
  char j;
L:
  j = k = ~(-(b * a) / f);
  c = -((1 - d / b) | ((c | 1 / j) - b));
  e = ~((1 & b) ^ e) / ~f;
  if (a)
printf ("%d", h);
  if (!(a || k < 2 || a))
e = j;
  if (a < d || e)
goto L;
  d = f && i;
  return 0;
}

[Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu

2023-06-26 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110391

--- Comment #2 from Zhendong Su  ---
A likely related reproducer that affects 10.* and later. 

Compiler Explorer: https://godbolt.org/z/KP6PnTKPj

[579] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230625 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[580] % 
[580] % gcctk -O2 -fsel-sched-pipelining -fschedule-insns
-fselective-scheduling2 small.c
[581] % ./a.out
Floating point exception
[582] % 
[582] % gcctk -O2 small.c; ./a.out
[583] % 
[583] % cat small.c
int printf(const char *, ...);
int a, d, e = -2;
char b;
long c = -2;
int main() {
  int g, h;
  d = e;
  g = c;
 L:
  h = d;
  c = 1;
  d = c % ~e;
  e = e >> ~g;
  if (e > b)
printf("%ld", c);
  if (g > c)
printf("%d", a);
  if (b)
goto L;
  e = h;
  return 0;
}

[Bug rtl-optimization/110390] ICE on valid code on x86_64-linux-gnu with sel-scheduling: in av_set_could_be_blocked_by_bookkeeping_p, at sel-sched.cc:3609

2023-06-24 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110390

--- Comment #1 from Zhendong Su  ---
Another reproducer with fewer flags (and affects 12.* and later).

Compiler Explorer: https://godbolt.org/z/fYqEz9EWx

[603] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230624 (experimental) [master r14-924-gd709841ae0f] (GCC)
[604] %
[604] % gcctk -O3 -fsel-sched-pipelining -fschedule-insns
-fselective-scheduling2 -fPIC small.c
during RTL pass: sched2
small.c: In function ‘h’:
small.c:20:1: internal compiler error: in
av_set_could_be_blocked_by_bookkeeping_p, at sel-sched.cc:3609
   20 | }
  | ^
0x7d635a av_set_could_be_blocked_by_bookkeeping_p
../../gcc-trunk/gcc/sel-sched.cc:3609
0x7d635a code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6386
0x7d635a code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6608
0xf85b69 code_motion_process_successors
../../gcc-trunk/gcc/sel-sched.cc:6342
0xf85b69 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6608
0xf86c18 find_used_regs
../../gcc-trunk/gcc/sel-sched.cc:3272
0xf86c18 collect_unavailable_regs_from_bnds
../../gcc-trunk/gcc/sel-sched.cc:1586
0xf86c18 find_best_reg_for_expr
../../gcc-trunk/gcc/sel-sched.cc:1649
0xf8976c fill_vec_av_set
../../gcc-trunk/gcc/sel-sched.cc:3784
0xf8976c fill_ready_list
../../gcc-trunk/gcc/sel-sched.cc:4014
0xf8976c find_best_expr
../../gcc-trunk/gcc/sel-sched.cc:4374
0xf8976c fill_insns
../../gcc-trunk/gcc/sel-sched.cc:5535
0xf8976c schedule_on_fences
../../gcc-trunk/gcc/sel-sched.cc:7353
0xf8976c sel_sched_region_2
../../gcc-trunk/gcc/sel-sched.cc:7491
0xf8a928 sel_sched_region_1
../../gcc-trunk/gcc/sel-sched.cc:7533
0xf8bf46 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7634
0xf8bf46 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7619
0xf8c0e9 run_selective_scheduling()
../../gcc-trunk/gcc/sel-sched.cc:7720
0xf6d7ed rest_of_handle_sched2
../../gcc-trunk/gcc/sched-rgn.cc:3743
0xf6d7ed execute
../../gcc-trunk/gcc/sched-rgn.cc:3890
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[605] %
[605] % cat small.c
static int a;
int b, c, d, g;
long e, f;
extern void l(char *);
void h() {
  char i;
  int j = 1 >> f / b;
 L:
  f = -(-(f % g || a) * (c && f | e));
  if (a > e)
l("");
  if (f) {
l("A");
i = j / g;
  }
  if (a)
goto L;
  d = i;
  a = 0;
}

[Bug rtl-optimization/110393] New: ICE at -O3 with "-fselective-scheduling2 -fPIC": in move_op_ascend, at sel-sched.cc:6150

2023-06-24 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110393

Bug ID: 110393
   Summary: ICE at -O3 with "-fselective-scheduling2 -fPIC": in
move_op_ascend, at sel-sched.cc:6150
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a regression from 12.*, and affects 13.* and later.

Compiler Explorer: https://godbolt.org/z/Tqsbhv461

[629] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230623 (experimental) [master r14-924-gd709841ae0f] (GCC)
[630] %
[630] % gcctk -O3 -fselective-scheduling2 -fPIC small.c
during RTL pass: sched2
small.c: In function ‘main’:
small.c:40:1: internal compiler error: in move_op_ascend, at sel-sched.cc:6150
   40 | }
  | ^
0x7d606f move_op_ascend
../../gcc-trunk/gcc/sel-sched.cc:6150
0x7d606f move_op_ascend
../../gcc-trunk/gcc/sel-sched.cc:6142
0xf85287 code_motion_path_driver
../../gcc-trunk/gcc/sel-sched.cc:6648
0xf85dd9 move_op
../../gcc-trunk/gcc/sel-sched.cc:6702
0xf85dd9 move_exprs_to_boundary
../../gcc-trunk/gcc/sel-sched.cc:5223
0xf85dd9 schedule_expr_on_boundary
../../gcc-trunk/gcc/sel-sched.cc:5436
0xf8834f fill_insns
../../gcc-trunk/gcc/sel-sched.cc:5578
0xf8834f schedule_on_fences
../../gcc-trunk/gcc/sel-sched.cc:7353
0xf8834f sel_sched_region_2
../../gcc-trunk/gcc/sel-sched.cc:7491
0xf8a568 sel_sched_region_1
../../gcc-trunk/gcc/sel-sched.cc:7533
0xf8bb86 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7634
0xf8bb86 sel_sched_region(int)
../../gcc-trunk/gcc/sel-sched.cc:7619
0xf8bd29 run_selective_scheduling()
../../gcc-trunk/gcc/sel-sched.cc:7720
0xf6d42d rest_of_handle_sched2
../../gcc-trunk/gcc/sched-rgn.cc:3743
0xf6d42d execute
../../gcc-trunk/gcc/sched-rgn.cc:3890
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[631] %
[631] % cat small.c
extern void r();
struct a {
  int b : 21;
  int c : 17;
  volatile int d : 3;
  int e;
} l;
int f, j, m, n, o;
volatile struct a g;
static struct a h, k;
static int i;
int main() {
  int p, u, v;
q:
  if (m) {
r();
if (j) {
  k.b = 0;
  goto s;
}
  }
  h.d;
t:
  u = f * (i || g.b | k.e);
  v = (f || 0) * (l.c - (50 & u));
  if (v) {
if (k.c)
  goto q;
  s:
if (u)
  goto w;
  }
  short a = p;
  o = -a * n;
  h.d = 0 > h.d;
  p = o;
  goto t;
w:
  return 0;
}

  1   2   3   4   >