https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112961
--- Comment #5 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:878cb5acf0c499702ffd315e273f55e8bd0970b8 commit r14-6457-g878cb5acf0c499702ffd315e273f55e8bd0970b8 Author: Richard Biener <rguent...@suse.de> Date: Tue Dec 12 14:01:47 2023 +0100 tree-optimization/112961 - include latch in if-conversion CSE The following makes sure to also process the (empty) latch when performing CSE on the if-converted loop body. That's important to get all uses of copies propagated out on the backedge as well. To avoid CSE on the PHI nodes itself which is prohibitive (see PR90402) this temporarily adds a fake entry edge to the loop. PR tree-optimization/112961 * tree-if-conv.cc (tree_if_conversion): Instead of excluding the latch block from VN, add a fake entry edge. * g++.dg/vect/pr112961.cc: New testcase.