]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/120687 - avoid disturbing reduction chains in reassoc
authorRichard Biener <rguenther@suse.de>
Tue, 29 Jul 2025 08:05:32 +0000 (10:05 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 29 Jul 2025 10:13:00 +0000 (12:13 +0200)
commite8a51144c02e1cf210db5763e435802ac6fa6ad9
tree409ce9ba618ecaf899655559e63b8016dd85fc38
parentc1102be3b25bde9989561b2610f8ee721a33a8e7
tree-optimization/120687 - avoid disturbing reduction chains in reassoc

Reassoc carefully ranks operands to form reduction chains for
vectorization so we are careful to not apply any width related
changes in the early pass.  Unfortunately we are not careful
enough.  The following gates fma related re-ordering and also
the >= 3 ops tail "optimization" which is the culprit here.

This does not fix the reported inefficient vectorization when
using signed integer reductions yet.

PR tree-optimization/120687
* tree-ssa-reassoc.cc (reassociate_bb): Do not disturb
the sorted operand order in the early pass.
* tree-vect-slp.cc (vect_analyze_slp): Dump when a detected
reduction chain fails SLP discovery.

* gcc.dg/vect/pr120687-1.c: New testcase.
* gcc.dg/vect/pr120687-2.c: Likewise.
gcc/testsuite/gcc.dg/vect/pr120687-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr120687-2.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.cc
gcc/tree-vect-slp.cc