[2/2] tree-optimization/124802 - avoid SLP_TREE_REPRESENTATIVE for permutes

Message ID 20260407135001.E93ED4BA2E26@sourceware.org
State New
Headers
Series [1/2] tree-optimization/124802 - wrong SLP pattern detection |

Commit Message

Richard Biener April 7, 2026, 1:48 p.m. UTC
  The following avoids having a SLP_TREE_REPRESENTATIVE for permute
nodes from two operator SLP matching.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.
And this I plan to push for stage1.

	PR tree-optimization/124802
	* tree-vect-slp.cc (vect_build_slp_tree_2): Reset
	SLP_TREE_REPRESENTATIVE for permute nodes built from
	a known set of scalar stmts.
---
 gcc/tree-vect-slp.cc | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 9d2d0f98ea8..aa442d53999 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3137,6 +3137,7 @@  fail:
 	      SLP_TREE_VECTYPE (pnode) = vectype;
 	      SLP_TREE_CHILDREN (pnode).quick_push (child);
 	      SLP_TREE_CHILDREN (pnode).quick_push (child);
+	      SLP_TREE_REPRESENTATIVE (pnode) = NULL;
 	      lane_permutation_t& perm = SLP_TREE_LANE_PERMUTATION (pnode);
 	      children.safe_push (pnode);
 
@@ -3166,6 +3167,7 @@  fail:
       SLP_TREE_CODE (node) = VEC_PERM_EXPR;
       SLP_TREE_CHILDREN (node).quick_push (one);
       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))