https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115981
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 58786 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58786&action=edit gcc15-pr115981.patch Untested fix. As since that commit it checks swap_commutative_operands_p: 1) CONST_VECTOR I think has commutative_operand_precedence -4 2) REG has commutative_operand_precedence -1 or -2 3) SUBREG of object has commutative_operand_precedence -3 4) VEC_DUPLICATE has commutative_operand_precedence 0 Which means the VEC_DUPLICATE operand will always come first and whatever matches reg_or_0_operand will always come second, i.e. exactly not the order in the pattern, so we don't need to add another one, can just change order of this one.