]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove bougs minimum VF compute
authorRichard Biener <rguenther@suse.de>
Mon, 21 Jul 2025 08:40:13 +0000 (10:40 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Jul 2025 10:52:27 +0000 (12:52 +0200)
The following removes the minimum VF compute from dataref analysis
which does not take into account SLP at all, leaving the testcase
vectorized with V2SImode instead of V4SImode on x86.  With SLP
the only minimum VF we can compute this early is 1.

* tree-vectorizer.h (vect_analyze_data_refs): Remove min_vf
output.
* tree-vect-data-refs.cc (vect_analyze_data_refs): Likewise.
* tree-vect-loop.cc (vect_analyze_loop_2): Remove early
out based on bogus min_vf.
* tree-vect-slp.cc (vect_slp_analyze_bb_1): Adjust.

* gcc.dg/vect/vect-127.c: New testcase.

gcc/testsuite/gcc.dg/vect/vect-127.c [new file with mode: 0644]
gcc/tree-vect-data-refs.cc
gcc/tree-vect-loop.cc
gcc/tree-vect-slp.cc
gcc/tree-vectorizer.h

diff --git a/gcc/testsuite/gcc.dg/vect/vect-127.c b/gcc/testsuite/gcc.dg/vect/vect-127.c
new file mode 100644 (file)
index 0000000..8b913dc
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-require-effective-target vect_int }
+
+void foo (int *p)
+{
+  for (int i = 0; i < 1024; ++i)
+    {
+      int a0 = p[2*i + 0];
+      int a1 = p[2*i + 1];
+      p[2*i + 4] = a0;
+      p[2*i + 5] = a1;
+    }
+}
+
+/* { dg-final { scan-tree-dump "loop vectorized using 16 byte vectors" "vect" { target { vect128 && vect_hw_misalign } } } } */
index c84cd29116edf2a48f7c8b5cd40debd7fbeab922..a24ddfbc3841770a18e183f784d7321bd4250e3b 100644 (file)
@@ -5056,7 +5056,7 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt,
 */
 
 opt_result
-vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf, bool *fatal)
+vect_analyze_data_refs (vec_info *vinfo, bool *fatal)
 {
   class loop *loop = NULL;
   unsigned int i;
@@ -5075,7 +5075,6 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf, bool *fatal)
   FOR_EACH_VEC_ELT (datarefs, i, dr)
     {
       enum { SG_NONE, GATHER, SCATTER } gatherscatter = SG_NONE;
-      poly_uint64 vf;
 
       gcc_assert (DR_REF (dr));
       stmt_vec_info stmt_info = vinfo->lookup_stmt (DR_STMT (dr));
@@ -5267,11 +5266,6 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf, bool *fatal)
                             stmt_info->stmt, vectype);
        }
 
-      /* Adjust the minimal vectorization factor according to the
-        vector type.  */
-      vf = TYPE_VECTOR_SUBPARTS (vectype);
-      *min_vf = upper_bound (*min_vf, vf);
-
       /* Leave the BB vectorizer to pick the vector type later, based on
         the final dataref group size and SLP node size.  */
       if (is_a <loop_vec_info> (vinfo))
index 8dfda2cb56d6df26ca17067a78ae5df657fb45d3..fe11eb72e4bb84870012c9d10a6afbd45b962fdf 100644 (file)
@@ -2373,7 +2373,6 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
   opt_result ok = opt_result::success ();
   int res;
   unsigned int max_vf = MAX_VECTORIZATION_FACTOR;
-  poly_uint64 min_vf = 2;
   loop_vec_info orig_loop_vinfo = NULL;
 
   /* If we are dealing with an epilogue then orig_loop_vinfo points to the
@@ -2420,7 +2419,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
   /* Analyze the data references and also adjust the minimal
      vectorization factor according to the loads and stores.  */
 
-  ok = vect_analyze_data_refs (loop_vinfo, &min_vf, &fatal);
+  ok = vect_analyze_data_refs (loop_vinfo, &fatal);
   if (!ok)
     {
       if (dump_enabled_p ())
@@ -2485,9 +2484,6 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
                         "bad data dependence.\n");
       return ok;
     }
-  if (max_vf != MAX_VECTORIZATION_FACTOR
-      && maybe_lt (max_vf, min_vf))
-    return opt_result::failure_at (vect_location, "bad data dependence.\n");
   LOOP_VINFO_MAX_VECT_FACTOR (loop_vinfo) = max_vf;
 
   ok = vect_set_stmts_vectype (loop_vinfo);
index 7c23496b5e0699b46eaba866762318f3686de4dc..7ad56b9a848a5d6bbd6b11339cdec5977e01ed81 100644 (file)
@@ -9570,14 +9570,13 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal,
 
   slp_instance instance;
   int i;
-  poly_uint64 min_vf = 2;
 
   /* The first group of checks is independent of the vector size.  */
   fatal = true;
 
   /* Analyze the data references.  */
 
-  if (!vect_analyze_data_refs (bb_vinfo, &min_vf, NULL))
+  if (!vect_analyze_data_refs (bb_vinfo, NULL))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
index 799d5fed7a9490e7a89f404c088d12376c61f2cd..80f8853733de566fcd3499b2ddeafa08a006b4d5 100644 (file)
@@ -2552,7 +2552,7 @@ extern bool vect_check_gather_scatter (stmt_vec_info, loop_vec_info,
 extern opt_result vect_find_stmt_data_reference (loop_p, gimple *,
                                                 vec<data_reference_p> *,
                                                 vec<int> *, int);
-extern opt_result vect_analyze_data_refs (vec_info *, poly_uint64 *, bool *);
+extern opt_result vect_analyze_data_refs (vec_info *, bool *);
 extern void vect_record_base_alignments (vec_info *);
 extern tree vect_create_data_ref_ptr (vec_info *,
                                      stmt_vec_info, tree, class loop *, tree,