https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105528
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 52941 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52941&action=edit gcc12-pr105528.patch Untested fix. gsi_remove moves iterator to the next stmt after the removed one, and the caller uses gsi_next, so if gsi_remove happened, the caller skips processing one stmt.