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<bool (rtl_ssa::insn_change&, unsigned int)>::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<bool (rtl_ssa::insn_change&, unsigned int)>) ../../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 <https://gcc.gnu.org/bugs/> 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; }