https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121659
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:52438e5e5808b6e8783fc59b77e028615946fbf3 commit r15-10354-g52438e5e5808b6e8783fc59b77e028615946fbf3 Author: Richard Biener <[email protected]> Date: Tue Aug 26 10:34:01 2025 +0200 tree-optimization/121659 - bogus swap of reduction operands The following addresses a bogus swapping of SLP operands of a reduction operation which gets STMT_VINFO_REDUC_IDX out of sync with the SLP operand order. In fact the most obvious mistake is that we simply swap operands even on the first stmt even when there's no difference in the comparison operators (for == and != at least). But there are more latent issues that I noticed and fixed up in the process. PR tree-optimization/121659 * tree-vect-slp.cc (vect_build_slp_tree_1): Do not allow matching up comparison operators by swapping if that would disturb STMT_VINFO_REDUC_IDX. Make sure to only actually mark operands for swapping when there was a mismatch and we're not processing the first stmt. * gcc.dg/vect/pr121659.c: New testcase. (cherry picked from commit 68e692eed9e8e8c47d83586ee08f40c27fa3a78d)
