https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121756
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:df64893e7082d7fae5d6863fd02371b37c78557f commit r16-3542-gdf64893e7082d7fae5d6863fd02371b37c78557f Author: Richard Biener <rguent...@suse.de> Date: Wed Sep 3 10:41:17 2025 +0200 tree-optimization/121756 - handle irreducible regions when sinking The sinking code currently does not heuristically avoid placing code into an irreducible region in the same way it avoids placing into a deeper loop nest. Critically for the PR we may not insert a VDEF into a irreducible region that does not contain a virtual definition. The following adds the missing heuristic and also a stop-gap for the VDEF issue - since we cannot determine validity inside an irreducible region we have to reject any VDEF movement with destination inside such region, even when it originates there. In particular irreducible sub-cycles are not tracked separately and can cause issues. I chose to not complicate the already partly incomplete assert but prune it down to essentials. PR tree-optimization/121756 * tree-ssa-sink.cc (select_best_block): Avoid irreducible regions in otherwise same loop depth. (statement_sink_location): When sinking a VDEF, never place that into an irreducible region. * gcc.dg/torture/pr121756.c: New testcase.