]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/121659 - bogus swap of reduction operands
authorRichard Biener <rguenther@suse.de>
Tue, 26 Aug 2025 08:34:01 +0000 (10:34 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 26 Aug 2025 11:00:16 +0000 (13:00 +0200)
commit68e692eed9e8e8c47d83586ee08f40c27fa3a78d
tree2dbe8cb9a4e62575730c3dbb677fec5a9aeb15ed
parentb01ae7a2b589e015617bed7110b6291c5ecd420c
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.
gcc/testsuite/gcc.dg/vect/pr121659.c [new file with mode: 0644]
gcc/tree-vect-slp.cc