https://gcc.gnu.org/g:6c3a8c553f98c8bdf42a24f49cbaa206b55c80d5
commit r17-4894-g6c3a8c553f98c8bdf42a24f49cbaa206b55c80d5 Author: Alex Coplan <[email protected]> Date: Fri Jul 24 11:51:53 2026 +0100 vect: Drop codes on two_operators slp nodes r17-71-g3f6d37193c7987ee9362c073dd5da6f7419c87b3 adds the following assert in vect_create_new_slp_node: gcc_assert (code == ERROR_MARK || code == VEC_PERM_EXPR); which seems to suggest that SLP nodes should only ever have one of these two codes. Recently I have been studying how the recognition of complex add with rotate works. There is code in vect_build_slp_tree_2 which, in the two_operators case, builds synthetic {PLUS,MINUS}_EXPR nodes which are then packed together with a permutation. This is later recognized by the complex add slp pattern. I noticed that this code sets the code fields of the synthetic nodes to the relevant tree codes, e.g. {PLUS,MINUS}_EXPR, but this isn't actually needed, since the pattern code just looks at the code of the representative stmt for non-permutation nodes. It's also at odds with the recently-added assert above. This patch therefore drops setting the codes on those nodes, and instead leaves them set to ERROR_MARK (meaning that consumers should look at the representative, as the patterns currently do). It is intended to be a non-functional cleanup. gcc/ChangeLog: * tree-vect-slp.cc (vect_build_slp_tree_2): In the two_operators case, avoid setting the code field on the plus/minus nodes. Diff: --- gcc/tree-vect-slp.cc | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 12b1abe3d786..142037ed0081 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3380,7 +3380,6 @@ fail: SLP_TREE_CHILDREN (node).quick_push (two); SLP_TREE_REPRESENTATIVE (node) = NULL; enum tree_code code0 = ERROR_MARK; - enum tree_code ocode = ERROR_MARK; if (gassign *stmt = dyn_cast <gassign *> (stmts[0]->stmt)) code0 = gimple_assign_rhs_code (stmt); stmt_vec_info ostmt_info; @@ -3388,28 +3387,17 @@ fail: FOR_EACH_VEC_ELT (stmts, i, ostmt_info) { int op = 0; - if (gassign *ostmt = dyn_cast <gassign *> (ostmt_info->stmt)) + gassign *ostmt = dyn_cast<gassign *> (ostmt_info->stmt); + if ((ostmt && gimple_assign_rhs_code (ostmt) != code0) + || (!ostmt + && gimple_call_combined_fn (stmts[0]->stmt) + != gimple_call_combined_fn (ostmt_info->stmt))) { - if (gimple_assign_rhs_code (ostmt) != code0) - { - ocode = gimple_assign_rhs_code (ostmt); - op = 1; - j = i; - } - } - else - { - if (gimple_call_combined_fn (stmts[0]->stmt) - != gimple_call_combined_fn (ostmt_info->stmt)) - { - op = 1; - j = i; - } + op = 1; + j = i; } SLP_TREE_LANE_PERMUTATION (node).safe_push (std::make_pair (op, i)); } - SLP_TREE_CODE (one) = code0; - SLP_TREE_CODE (two) = ocode; SLP_TREE_LANES (one) = stmts.length (); SLP_TREE_LANES (two) = stmts.length (); SLP_TREE_REPRESENTATIVE (one) = stmts[0];
