https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97953
--- Comment #15 from Martin Liška <marxin at gcc dot gnu.org> --- Created attachment 49624 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49624&action=edit debugging patch All right it will be for Richi. I suspect it's a do_hoist_insertion. reduced test-case: $ cat /tmp/bid.i int __bid_ten2k64_res_0, __bid_ten2k64_ind; void __bid_round64_2_18(); void __bid_ten2k64() { for (; __bid_ten2k64_ind <= 9; __bid_ten2k64_ind++) if (__bid_ten2k64_res_0) break; if (__bid_ten2k64_ind) __bid_round64_2_18(); } Steps to reproduce: 1) git co bd87cc14ebdb6789e067fb1828d5808407c308b3 2) patch -p1 < debug.patch 3) mkdir objdir 4) cd objdir 5) ../configure --disable-checking --disable-werror --enable-languages=c,c++,fortran --disable-multilib 6) make -j16 (you can also use make -j16 'STAGE1_CFLAGS=-g -O2') ... then it build stage2 compiler and crashes in somewhere in libgcc (using the compiler) $ ./gcc/xgcc -Bgcc /tmp/bid.i -O2 -c -fverbose-asm __bid_ten2k64_ind.2_11 = PHI <_3(13), __bid_ten2k64_ind.2_12(4)> use->stmt: 0x7ffff7548400, use->stmt->code: 18 _3 = __bid_ten2k64_ind.2_11 + 1; cand->incremented_at: 0x7ffff7544000, cand->incremented_at->code: 6 during GIMPLE pass: ivopts /tmp/bid.i: In function ‘__bid_ten2k64’: /tmp/bid.i:4:6: internal compiler error: XXXXXX, code==18 4 | void __bid_ten2k64() { | ^~~~~~~~~~~~~ 0x7ffff7695151 __libc_start_main ../csu/libc-start.c:314 0x5ffafd ??? ../sysdeps/x86_64/start.S:120 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. as seen rewrite_use_nonlinear_expr is miscompiled where code == 18 is GIMPLE_PHI which is handled in the switch You can do: $ cd gcc $ /home/marxin/Programming/gcc2/objdir/./prev-gcc/xg++ -B/home/marxin/Programming/gcc2/objdir/./prev-gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include -I/home/marxin/Programming/gcc2/libstdc++-v3/libsupc++ -L/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -fno-PIE -c -g -O2 -fno-checking -gtoggle -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace -o tree-ssa-loop-ivopts.o -MT tree-ssa-loop-ivopts.o -MMD -MP -MF ./.deps/tree-ssa-loop-ivopts.TPo ../../gcc/tree-ssa-loop-ivopts.c -fdbg-cnt=hoisting:932-933 && m && ./xgcc -B. -O2 -c /tmp/bid.i -fverbose-asm as seen is first bad debug counter value: -fdbg-cnt=hoisting:932-933, good one is: -fdbg-cnt=hoisting:932-932 or you can find your value with dbgcnt-bisect.py '/home/marxin/Programming/gcc2/objdir/./prev-gcc/xg++ -B/home/marxin/Programming/gcc2/objdir/./prev-gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/include -I/home/marxin/Programming/gcc2/libstdc++-v3/libsupc++ -L/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/marxin/Programming/gcc2/objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -fno-PIE -c -g -O2 -fno-checking -gtoggle -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace -o tree-ssa-loop-ivopts.o -MT tree-ssa-loop-ivopts.o -MMD -MP -MF ./.deps/tree-ssa-loop-ivopts.TPo ../../gcc/tree-ssa-loop-ivopts.c' 'make -j16 && ./xgcc -B. -O2 -c /tmp/bid.i' hoisting 2000 The script is from: https://github.com/marxin/script-misc