https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97559
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so as expected this is static bool statement_sink_location (gimple *stmt, basic_block frombb, gimple_stmt_iterator *togsi, bool *zero_uses_p) { ... /* If this is a load then do not sink past any stores. Look for virtual definitions in the path from frombb to the sink location computed from the real uses and if found, adjust that it a common dominator. */ if (gimple_vuse (stmt)) { ... FOR_EACH_IMM_USE_FAST (use_p, imm_iter, gimple_vuse (stmt)) { ... /* In case the PHI node post-dominates the current insert location we can disregard it. But make sure it is not dominating it as well as can happen in a CFG cycle. */ if (commondom != bb && !dominated_by_p (CDI_DOMINATORS, commondom, bb) && dominated_by_p (CDI_POST_DOMINATORS, commondom, bb)) continue; where the use stmt is in an irreducible region and thus the dominance check breaks down. We want to avoid doing a full 'is use_stmt' on a path from bb to commondom check and thus are employing some heuristics to capture most cases. We do have natural loops computed here and irreducible regions marked, need to think about an adjustment to the above. Meanwhile more testcases are always welcome.