]> git.ipfire.org Git - thirdparty/gcc.git/commit
Swap operands during SLP discovery for mismatching STMT_VINFO_REDUC_IDX
authorRichard Biener <rguenther@suse.de>
Thu, 30 Oct 2025 09:38:13 +0000 (10:38 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 30 Oct 2025 10:38:16 +0000 (11:38 +0100)
commit7ea81ee5e57e4a5d6a6975c4bffde59751aa87f2
tree38c46775201e9b7bf0725c552768c5b87bd2f1e6
parentc45a8fb11ae0c57bca052765742df6c8ad91f164
Swap operands during SLP discovery for mismatching STMT_VINFO_REDUC_IDX

When we are unlucky operand canonicalization can end up presenting
us with different order, making a possible SLP reduction group
not match up.  The following allows swapping operands in this case.

* tree-vect-slp.cc (vect_get_operand_map): Handle commutative
operands when swapping is requested.
(vect_build_slp_tree_1): Allow STMT_VINFO_REDUC_IDX differences
when operand swapping makes them match and request swapping.
(vect_build_slp_instance): Indicate we have successfully
discovered a SLP reduction group.

* gcc.dg/vect/slp-reduc-13.c: New testcase.

Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
gcc/testsuite/gcc.dg/vect/slp-reduc-13.c [new file with mode: 0644]
gcc/tree-vect-slp.cc