https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110317

--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Here is another related reproducer that only needs -fselective-scheduling2.

It affects 13.* and later.

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

[593] % 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) 
[594] % 
[594] % gcctk -O3 -fselective-scheduling2 small.c
during RTL pass: sched2
small.c: In function ā€˜j’:
small.c:17:1: internal compiler error: in move_exprs_to_boundary, at
sel-sched.cc:5228
   17 | }
      | ^
0x7d651c move_exprs_to_boundary
        ../../gcc-trunk/gcc/sel-sched.cc:5228
0x7d651c 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 <https://gcc.gnu.org/bugs/> for instructions.
[595] % 
[595] % cat small.c
int a, b, *c, d, f, h;
int ***volatile e;
short g;
extern int k();
static void i() {
  while (1) {
    if (d && f)
      while (1)
        ;
    h = 1;
    (a ^= ***e) | (*c ^= (g = (b > 8) << h) && f);
  }
}
void j() {
  if (b && k())
    i();
}

Reply via email to