https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90637
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so sinking computes the correct block to sink to in sinkbb = gimple_bb (use); sinkbb = select_best_block (frombb, gimple_bb (use), stmt); if (sinkbb == frombb) return false; *togsi = gsi_for_stmt (use); but then picks 'use' for togsi even though that is in a different block... The following fixes it: Index: gcc/tree-ssa-sink.c =================================================================== --- gcc/tree-ssa-sink.c (revision 271644) +++ gcc/tree-ssa-sink.c (working copy) @@ -439,7 +439,10 @@ statement_sink_location (gimple *stmt, b if (sinkbb == frombb) return false; - *togsi = gsi_for_stmt (use); + if (sinkbb == gimple_bb (use)) + *togsi = gsi_for_stmt (use); + else + *togsi = gsi_after_labels (sinkbb); return true; }