https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99165
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think there are two problems, one as that apparently the pass can be tricked into processing the stores it emitted again and the other, possibly related, that the dominators are wrong with the non-call-exceptions store merging. pass_store_merging::execute already uses gsi_next before calling process_store / terminate_all_aliasing_chains, so I think it can't happen without non-call-exceptions store merging, but perhaps we need to update bb from gsi_stmt (gsi). No idea how to discover if we'd add a new bb and gsi_empty_p (gsi) would be true. Perhaps we need to mark in bb flags whether it is a bb meant for store merging and not set it on newly created bbs (but let those have the end processed through gsi_next).