https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116842
--- Comment #7 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:71bf3daa8dabe45aa14e7315195a70ad0d883337 commit r15-3957-g71bf3daa8dabe45aa14e7315195a70ad0d883337 Author: Richard Biener <rguent...@suse.de> Date: Sat Sep 28 14:02:18 2024 +0200 tree-optimization/116842 - vectorizer load hosting breaks UID order The following fixes the case when vectorizing a load hoists an invariant load and dependent stmts, thereby breaking UID order of said stmts. While we duplicate the load we just move the dependences. PR tree-optimization/116842 * tree-vect-stmts.cc (hoist_defs_of_uses): Sort stmts to hoist after UID to avoid breaking vect_stmt_dominates_stmt_p. * g++.dg/torture/pr116842.C: New testcase.