https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106568
--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> --- Try -fsanitize=unreachable - when reordering BBs makes crashes appear/disappear the most likely culprit is we run into a path deemed unreachable which means we fall through to random code. You can also try looking at the -fdump-tree-optimized dump and find the function that's not catching what it is supposed to catch to see if there's any __builtin_unreachable () calls around.