https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106860
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:4ce316ca54c863cf0fd4257ba0ab768ab83c62e5 commit r12-8753-g4ce316ca54c863cf0fd4257ba0ab768ab83c62e5 Author: Richard Biener <rguent...@suse.de> Date: Wed Sep 7 10:44:33 2022 +0200 tree-optimization/106860 - fix profile scaling in split_loop The following fixes a mistake in loop splitting which assumes loop latches have a single predecessor and that edge is from the exit test. Instead work from the single exit edge we have to find the edge towards the latch. PR tree-optimization/106860 * tree-ssa-loop-split.cc (split_loop): Find the exit to latch edge from the loop exit edge instead of from the latch. Verify we're going to find it. * g++.dg/opt/pr106860.C: New testcase. (cherry picked from commit 0386609923577e07354ee63754795b2f729e7e00)