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

            Bug ID: 116343
           Summary: ICE on valid code at -Os with "-fschedule-insns
                    -fno-thread-jumps -fno-dce" on x86_64-linux-gnu: in
                    extract_insn, at recog.cc:2869
           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 appears to be a recent regression as it doesn't reproduce with 14.2 and
earlier. 

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

[531] % 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 20240807 (experimental) (GCC) 
[532] % 
[532] % gcctk -Os -fschedule-insns -fno-thread-jumps -fno-dce small.c
small.c: In function ‘main’:
small.c:16:1: error: unrecognizable insn:
   16 | }
      | ^
(insn 42 38 89 9 (parallel [
            (set (reg:SI 103 [ a_lsm.11 ])
                (reg:SI 103 [ a_lsm.11 ]))
            (clobber (reg:CC 17 flags))
        ]) "small.c":3:40 discrim 1 -1
     (expr_list:REG_UNUSED (reg:CC 17 flags)
        (expr_list:REG_EQUAL (const_int 1 [0x1])
            (nil))))
during RTL pass: sched1
small.c:16:1: internal compiler error: in extract_insn, at recog.cc:2869
0x24fe5c5 internal_error(char const*, ...)
        ../../gcc-trunk/gcc/diagnostic-global-context.cc:491
0xa50e04 fancy_abort(char const*, int, char const*)
        ../../gcc-trunk/gcc/diagnostic.cc:1772
0x85641a _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        ../../gcc-trunk/gcc/rtl-error.cc:108
0x85643c _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        ../../gcc-trunk/gcc/rtl-error.cc:116
0x854533 extract_insn(rtx_insn*)
        ../../gcc-trunk/gcc/recog.cc:2869
0x2401d87 get_implicit_reg_pending_clobbers(HARD_REG_SET*, rtx_insn*)
        ../../gcc-trunk/gcc/sched-deps.cc:2886
0x24032cc sched_analyze_insn
        ../../gcc-trunk/gcc/sched-deps.cc:2905
0x240422e deps_analyze_insn(deps_desc*, rtx_insn*)
        ../../gcc-trunk/gcc/sched-deps.cc:3707
0x2404757 sched_analyze(deps_desc*, rtx_insn*, rtx_insn*)
        ../../gcc-trunk/gcc/sched-deps.cc:3860
0x1132b15 compute_block_dependences
        ../../gcc-trunk/gcc/sched-rgn.cc:2738
0x1132b15 sched_rgn_compute_dependencies(int)
        ../../gcc-trunk/gcc/sched-rgn.cc:3367
0x1135608 schedule_region
        ../../gcc-trunk/gcc/sched-rgn.cc:3139
0x1135608 schedule_insns()
        ../../gcc-trunk/gcc/sched-rgn.cc:3525
0x1135b87 schedule_insns()
        ../../gcc-trunk/gcc/sched-rgn.cc:3511
0x1135b87 rest_of_handle_sched
        ../../gcc-trunk/gcc/sched-rgn.cc:3729
0x1135b87 execute
        ../../gcc-trunk/gcc/sched-rgn.cc:3839
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.
[533] % 
[533] % cat small.c
int a, b, c;
volatile int d;
int e(int f, int g) { return g > 1 ? 1 : f >> g; }
int main() {
  int *i = &a;
  long j[1];
  if (a)
    while (1) {
      a ^= 1;
      if (*i)
        while (1)
          ;
      b = c && e((d, 1) >= 1, j[0]);
    }
  return 0;
}

Reply via email to