https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112464
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Robin Dapp <rd...@gcc.gnu.org>: https://gcc.gnu.org/g:d7b971cf61ae0091dbc777c9aa056e6f1293da2f commit r14-5322-gd7b971cf61ae0091dbc777c9aa056e6f1293da2f Author: Robin Dapp <rd...@ventanamicro.com> Date: Fri Nov 10 08:56:18 2023 +0100 vect: Look through pattern stmt in fold_left_reduction. It appears as if we "look through" a statement pattern in vect_finish_replace_stmt but not before when we replace the newly created vector statement's lhs. Then the lhs is the statement pattern's lhs while in vect_finish_replace_stmt we assert that it's from the statement the pattern replaced. This patch uses vect_orig_stmt on the scalar destination's definition so the replaced statement is used everywhere. gcc/ChangeLog: PR tree-optimization/112464 * tree-vect-loop.cc (vectorize_fold_left_reduction): Use vect_orig_stmt on scalar_dest_def_info. gcc/testsuite/ChangeLog: * gcc.target/i386/pr112464.c: New test.