https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78812
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The problem is that the hoisting code seems to assume the hoisting would be performed at the end of a bb, but that is not what insert_insn_end_basic_block will then actually do. But by the time insert_insn_end_basic_block is called, it is too late to punt or find another bb to hoist it to. compute_transp only analyzes transparency across the whole bb (to my surprise, it considers all calls as potentially clobbering MEMs, not just non-const/pure functions). So I think we want to have some predicate for what insert_insn_end_basic_block does to emit before the end of bb while searching for which bb to hoist to, and if that predicate is true, if it is a CALL (non-const/pure?) then not consider that bb for expressions containing MEMs (dunno if jumps could clobber MEMs too). Or just check for this and occrs_to_hoist.release (); if it happens in the if (hoistable > 1 && dbg_cnt (hoist_insn)) block or so?