]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/117147 - bogus re-use of previous ldst_p
authorRichard Biener <rguenther@suse.de>
Tue, 15 Oct 2024 07:22:09 +0000 (09:22 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 15 Oct 2024 09:06:30 +0000 (11:06 +0200)
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.

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

index 16332e0b6d7409d6e1d4185a4762ff4b281796cc..8727246c27a6deeacdfc32c7ee1bf07e0963f73a 100644 (file)
@@ -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))
        {