https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81192
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tom at codesourcery dot com --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Ugh. Tail-merging does very stupid stuff here, commoning a loop header with an inner loop latch. Now it _seems_ to me we run into a pre-existing bug in same_succ_flush_bbs that 'same' might be NULL. But it seems to be NULL from the start... The following fixes it but not tail-mergings stupid (dangerous?) transform that messes up loops. Where do we get a chance to "cancel" merging candidates? We should cancel any that do not belong to the same loop father. Index: gcc/tree-ssa-tail-merge.c =================================================================== --- gcc/tree-ssa-tail-merge.c (revision 249645) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -810,7 +810,9 @@ same_succ_flush_bb (basic_block bb) { same_succ *same = BB_SAME_SUCC (bb); BB_SAME_SUCC (bb) = NULL; - if (bitmap_single_bit_set_p (same->bbs)) + if (! same) + ; + else if (bitmap_single_bit_set_p (same->bbs)) same_succ_htab->remove_elt_with_hash (same, same->hashval); else bitmap_clear_bit (same->bbs, bb->index); Tom?