diff mbox series

tree-optimization/117147 - bogus re-use of previous ldst_p

Message ID 20241015082607.4F941385840A@sourceware.org
State New
Headers show
Series tree-optimization/117147 - bogus re-use of previous ldst_p | expand

Commit Message

Richard Biener Oct. 15, 2024, 8:25 a.m. UTC
The following shows that in vect_build_slp_tree_1 we're eventually
re-using the previous lane set ldst_p flag.  Fixed by some
refactoring.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/117147
	* tree-vect-slp.cc (vect_build_slp_tree_1): Put vars and
	initialization of per-lane data into the per-lane processing
	loop to avoid re-using previous lane state.
---
 gcc/tree-vect-slp.cc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 16332e0b6d7..8727246c27a 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1072,14 +1072,13 @@  vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
   stmt_vec_info first_stmt_info = stmts[0];
   code_helper first_stmt_code = ERROR_MARK;
   code_helper alt_stmt_code = ERROR_MARK;
-  code_helper rhs_code = ERROR_MARK;
   code_helper first_cond_code = ERROR_MARK;
   tree lhs;
   bool need_same_oprnds = false;
-  tree vectype = NULL_TREE, first_op1 = NULL_TREE;
+  tree first_op1 = NULL_TREE;
   stmt_vec_info first_load = NULL, prev_first_load = NULL;
-  bool first_stmt_ldst_p = false, ldst_p = false;
-  bool first_stmt_phi_p = false, phi_p = false;
+  bool first_stmt_ldst_p = false;
+  bool first_stmt_phi_p = false;
   int first_reduc_idx = -1;
   bool maybe_soft_fail = false;
   tree soft_fail_nunits_vectype = NULL_TREE;
@@ -1088,6 +1087,10 @@  vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
   stmt_vec_info stmt_info;
   FOR_EACH_VEC_ELT (stmts, i, stmt_info)
     {
+      bool ldst_p = false;
+      bool phi_p = false;
+      code_helper rhs_code = ERROR_MARK;
+
       swap[i] = 0;
       matches[i] = false;
       if (!stmt_info)
@@ -1139,7 +1142,7 @@  vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
 	  return false;
 	}
 
-      tree nunits_vectype;
+      tree vectype, nunits_vectype;
       if (!vect_get_vector_types_for_stmt (vinfo, stmt_info, &vectype,
 					   &nunits_vectype, group_size))
 	{