https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120687
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:c19aedfc0c3531e2c2b7c92e7b062be29ecbf0f8 commit r16-4726-gc19aedfc0c3531e2c2b7c92e7b062be29ecbf0f8 Author: Richard Biener <[email protected]> Date: Fri Oct 24 12:31:54 2025 +0200 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.
