]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/120687 - legitimise some permutes before optimizing
authorRichard Biener <rguenther@suse.de>
Fri, 24 Oct 2025 10:31:54 +0000 (12:31 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 30 Oct 2025 08:10:54 +0000 (09:10 +0100)
commitc19aedfc0c3531e2c2b7c92e7b062be29ecbf0f8
treee5e7ae0797efeacef53de49f812ffb3ee3093c59
parentacdf675933d549f2fe2c89e4feabcf36e382b4f5
tree-optimization/120687 - legitimise some permutes before optimizing

The following does a simple legitimising attempt on the SLP graph
permutations before trying to optimize them.  For the case we have
a single non-zero layout we can force that to all partitions if
it is compatible.  This way we end up with the most canonical
(and possibly no-op) load permutations and permutes.

I have refrained from trying to use internal_node_cost to actually
check if the result is legitimate (it would need at least the
change to anticipate redundant load permute eliding).  This relies
on start_choosing_layouts chosing layout zero for everything we
cannot handle (like non-bijective permutes).

What's still missing is to try to process disconnected parts of the
SLP graph separately.  We should possibly try to handle those
separately through all of the SLP optimize process for simplicity.

This also includes a fix for a dumping ICE when we permute the
root node of a reduction chain that was associated.

PR tree-optimization/120687
* tree-vect-slp.cc (vect_optimize_slp_pass::is_compatible_layout):
New overload for checking a whole partition.
(vect_optimize_slp_pass::legitimize): New function trying
a single layout for all partitions for now.
(vect_optimize_slp_pass::run): Try legitimizing to a single
layout before propagating.
(vect_slp_analyze_operations): For dumping deal with
SLP_TREE_SCALAR_STMTS being empty or element zero being NULL.
gcc/tree-vect-slp.cc