https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121236
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- + /* Remove the phi and move to the next phi arg if needed. */ + if (phi == gsi_stmt (*pgsi)) + remove_phi_node (pgsi, false); Needs to be fixed too. It should be something like: /* Move to the next phi if needed. */ if (phi == gsi_stmt (*pgsi)) gsi_next (pgsi); /* Remove the phi as it is no longer used. */ remove_phi_node (gsi_for_stmt (phi), false);