]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use the number of relevant stmts to limit SLP build
authorRichard Biener <rguenther@suse.de>
Tue, 3 Dec 2024 07:52:48 +0000 (08:52 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 3 Dec 2024 11:29:13 +0000 (12:29 +0100)
The following removes scalar stmt counting from loop vectorization
and using that as base to limit both the SLP tree final size and
discovery.  Instead use the number of relevant stmts for that
which is conveniently the number of stmt_vec_infos we create which
in turn includes things like pattern stmts.

PR tree-optimization/117874
* tree-vectorizer.h (vec_info_shared::n_stmts): Remove.
(LOOP_VINFO_N_STMTS): Likewise.
* tree-vectorizer.cc (vec_info_shared::vec_info_shared): Adjust.
* tree-vect-loop.cc (vect_get_datarefs_in_loop): Do not
count stmts.
(vect_analyze_loop_2): Adjust.  Pass stmt_vec_info.length ()
to vect_analyze_slp as SLP tree size limit.

gcc/tree-vect-loop.cc
gcc/tree-vectorizer.cc
gcc/tree-vectorizer.h

index 85209604486ae37d080f9a2bdc0891705daa6983..4f401cd2d0c40fea93397cd02de9df04b820a100 100644 (file)
@@ -2499,10 +2499,8 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo,
 
 static opt_result
 vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs,
-                          vec<data_reference_p> *datarefs,
-                          unsigned int *n_stmts)
+                          vec<data_reference_p> *datarefs)
 {
-  *n_stmts = 0;
   for (unsigned i = 0; i < loop->num_nodes; i++)
     for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]);
         !gsi_end_p (gsi); gsi_next (&gsi))
@@ -2510,7 +2508,6 @@ vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs,
        gimple *stmt = gsi_stmt (gsi);
        if (is_gimple_debug (stmt))
          continue;
-       ++(*n_stmts);
        opt_result res = vect_find_stmt_data_reference (loop, stmt, datarefs,
                                                        NULL, 0);
        if (!res)
@@ -2786,8 +2783,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
     {
       opt_result res
        = vect_get_datarefs_in_loop (loop, LOOP_VINFO_BBS (loop_vinfo),
-                                    &LOOP_VINFO_DATAREFS (loop_vinfo),
-                                    &LOOP_VINFO_N_STMTS (loop_vinfo));
+                                    &LOOP_VINFO_DATAREFS (loop_vinfo));
       if (!res)
        {
          if (dump_enabled_p ())
@@ -2898,7 +2894,7 @@ start_over:
     {
       /* Check the SLP opportunities in the loop, analyze and build
         SLP trees.  */
-      ok = vect_analyze_slp (loop_vinfo, LOOP_VINFO_N_STMTS (loop_vinfo),
+      ok = vect_analyze_slp (loop_vinfo, loop_vinfo->stmt_vec_infos.length (),
                             slp == 1);
       if (!ok)
        return ok;
index 9a068a408647ddd23fc1f7c8f29c0549c8f78029..0bec28048f4d09f7e97b3c74c85cd54b1c08d5ce 100644 (file)
@@ -480,8 +480,7 @@ vec_info::~vec_info ()
 }
 
 vec_info_shared::vec_info_shared ()
-  : n_stmts (0),
-    datarefs (vNULL),
+  : datarefs (vNULL),
     datarefs_copy (vNULL),
     ddrs (vNULL)
 {
index 7f69a3f57b492ad9ecbd63ecdea27e9abe386ac5..1059fc5c18f5fd80eea291a34ba6007384d97ddb 100644 (file)
@@ -474,9 +474,6 @@ public:
   void save_datarefs();
   void check_datarefs();
 
-  /* The number of scalar stmts.  */
-  unsigned n_stmts;
-
   /* All data references.  Freed by free_data_refs, so not an auto_vec.  */
   vec<data_reference_p> datarefs;
   vec<data_reference> datarefs_copy;
@@ -1070,7 +1067,6 @@ public:
 #define LOOP_VINFO_RGROUP_IV_TYPE(L)       (L)->rgroup_iv_type
 #define LOOP_VINFO_PARTIAL_VECTORS_STYLE(L) (L)->partial_vector_style
 #define LOOP_VINFO_PTR_MASK(L)             (L)->ptr_mask
-#define LOOP_VINFO_N_STMTS(L)             (L)->shared->n_stmts
 #define LOOP_VINFO_LOOP_NEST(L)            (L)->shared->loop_nest
 #define LOOP_VINFO_DATAREFS(L)             (L)->shared->datarefs
 #define LOOP_VINFO_DDRS(L)                 (L)->shared->ddrs