https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81245
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > The fix: > Index: gcc/tree-if-conv.c > =================================================================== > --- gcc/tree-if-conv.c (revision 249769) > +++ gcc/tree-if-conv.c (working copy) > @@ -1853,8 +1853,8 @@ > new_stmt = gimple_build_assign (res, rhs); > gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); > gimple_stmt_iterator new_gsi = gsi_for_stmt (new_stmt); > + update_stmt (new_stmt); > fold_stmt (&new_gsi, ifcvt_follow_ssa_use_edges); > - update_stmt (new_stmt); > > if (dump_file && (dump_flags & TDF_DETAILS)) > { Actually if (fold_stmt (...)) update_stmt (gsi_stmt (new_gsi)); is correct ;) The old update_stmt was redundant (gsi_insert_before updates the stmt already). fold_stmt may replace the stmt so with your fix you might just end up updating a stale one...