remove premature vect_verify_datarefs_alignment
authorRichard Biener <rguenther@suse.de>
Wed, 8 Jul 2020 14:37:55 +0000 (16:37 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 9 Jul 2020 11:17:07 +0000 (13:17 +0200)
This followup removes vect_verify_datarefs_alignment and its
premature cancellation of vectorization leaving the actual
decision whether alignment is supported to the functions
deciding whether we can vectorize a load or store.

2020-07-08  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_verify_datarefs_alignment): Remove.
(vect_slp_analyze_and_verify_instance_alignment): Rename to ...
(vect_slp_analyze_instance_alignment): ... this.
* tree-vect-data-refs.c (verify_data_ref_alignment): Remove.
(vect_verify_datarefs_alignment): Likewise.
(vect_enhance_data_refs_alignment): Do not call
vect_verify_datarefs_alignment.
(vect_slp_analyze_node_alignment): Rename from
vect_slp_analyze_and_verify_node_alignment and do not
call verify_data_ref_alignment.
(vect_slp_analyze_instance_alignment): Rename from
vect_slp_analyze_and_verify_instance_alignment.
* tree-vect-stmts.c (vectorizable_store): Dump when
we vectorize an unaligned access.
(vectorizable_load): Likewise.
* tree-vect-loop.c (vect_analyze_loop_2): Do not call
vect_verify_datarefs_alignment.
* tree-vect-slp.c (vect_slp_analyze_bb_1): Adjust.

* gcc.dg/vect/bb-slp-10.c: Adjust.
* gcc.dg/vect/slp-45.c: Likewise.
* gcc.dg/vect/vect-109.c: Likewise.

gcc/testsuite/gcc.dg/vect/bb-slp-10.c
gcc/testsuite/gcc.dg/vect/slp-45.c
gcc/testsuite/gcc.dg/vect/vect-109.c
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop.c
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index 1f9b917dcd26721fccc787d7e4f22af9d44b35e8..ad6f878e4076a9aa969efbc35d747dbcbd43c72b 100644 (file)
@@ -49,6 +49,6 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "bad data alignment in basic block" "slp2" { target { ! vect_element_align } } } } */
+/* { dg-final { scan-tree-dump "unsupported unaligned access" "slp2" { target { ! vect_element_align } } } } */
 /* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "slp2" { target vect_element_align } } } */
   
index d83472ca0954089bd09d0aedfa3b452a9a43c72d..1e35d354203f903bc7977f676e73f2cf0bf30e3c 100644 (file)
@@ -77,5 +77,4 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" { target vect_hw_misalign } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { ! vect_hw_misalign } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" } } */
index ac5d0827899471d6806ec719dab1dbbb7c3968d2..fe7ea6c420fb1512286b0b468cbe9ffed5daae71 100644 (file)
@@ -77,6 +77,6 @@ int main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_element_align } } } */
-/* { dg-final { scan-tree-dump-times "not vectorized: unsupported unaligned store" 2 "vect" { xfail vect_element_align } } } */
+/* { dg-final { scan-tree-dump-times "unsupported unaligned access" 2 "vect" { xfail vect_element_align } } } */
 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target vect_element_align xfail { ! vect_unaligned_possible } } } } */
 
index 2b4421b5fb492c2dac0fdf6ed89d77baa1d48af3..e35a215e042478d11d6545f1f829d816d0c3620f 100644 (file)
@@ -1214,56 +1214,6 @@ vect_relevant_for_alignment_p (dr_vec_info *dr_info)
   return true;
 }
 
-/* Function verify_data_ref_alignment
-
-   Return TRUE if DR_INFO can be handled with respect to alignment.  */
-
-static opt_result
-verify_data_ref_alignment (vec_info *vinfo, dr_vec_info *dr_info)
-{
-  enum dr_alignment_support supportable_dr_alignment
-    = vect_supportable_dr_alignment (vinfo, dr_info, false);
-  if (!supportable_dr_alignment)
-    return opt_result::failure_at
-      (dr_info->stmt->stmt,
-       DR_IS_READ (dr_info->dr)
-       ? "not vectorized: unsupported unaligned load: %T\n"
-       : "not vectorized: unsupported unaligned store: %T\n",
-       DR_REF (dr_info->dr));
-
-  if (supportable_dr_alignment != dr_aligned && dump_enabled_p ())
-    dump_printf_loc (MSG_NOTE, vect_location,
-                    "Vectorizing an unaligned access.\n");
-
-  return opt_result::success ();
-}
-
-/* Function vect_verify_datarefs_alignment
-
-   Return TRUE if all data references in the loop can be
-   handled with respect to alignment.  */
-
-opt_result
-vect_verify_datarefs_alignment (loop_vec_info loop_vinfo)
-{
-  vec<data_reference_p> datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
-  struct data_reference *dr;
-  unsigned int i;
-
-  FOR_EACH_VEC_ELT (datarefs, i, dr)
-    {
-      dr_vec_info *dr_info = loop_vinfo->lookup_dr (dr);
-      if (!vect_relevant_for_alignment_p (dr_info))
-       continue;
-
-      opt_result res = verify_data_ref_alignment (loop_vinfo, dr_info);
-      if (!res)
-       return res;
-    }
-
-  return opt_result::success ();
-}
-
 /* Given an memory reference EXP return whether its alignment is less
    than its size.  */
 
@@ -2091,13 +2041,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
 
       /* Check if all datarefs are supportable and log.  */
       if (do_peeling && known_alignment_for_access_p (dr0_info) && npeel == 0)
-        {
-          opt_result stat = vect_verify_datarefs_alignment (loop_vinfo);
-          if (!stat)
-            do_peeling = false;
-          else
-           return stat;
-        }
+       return opt_result::success ();
 
       /* Cost model #1 - honor --param vect-max-peeling-for-alignment.  */
       if (do_peeling)
@@ -2186,9 +2130,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
          /* The inside-loop cost will be accounted for in vectorizable_load
             and vectorizable_store correctly with adjusted alignments.
             Drop the body_cst_vec on the floor here.  */
-         opt_result stat = vect_verify_datarefs_alignment (loop_vinfo);
-         gcc_assert (stat);
-          return stat;
+         return opt_result::success ();
         }
     }
 
@@ -2318,16 +2260,13 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
       /* Peeling and versioning can't be done together at this time.  */
       gcc_assert (! (do_peeling && do_versioning));
 
-      opt_result stat = vect_verify_datarefs_alignment (loop_vinfo);
-      gcc_assert (stat);
-      return stat;
+      return opt_result::success ();
     }
 
   /* This point is reached if neither peeling nor versioning is being done.  */
   gcc_assert (! (do_peeling || do_versioning));
 
-  opt_result stat = vect_verify_datarefs_alignment (loop_vinfo);
-  return stat;
+  return opt_result::success ();
 }
 
 
@@ -2431,7 +2370,7 @@ vect_analyze_data_refs_alignment (loop_vec_info loop_vinfo)
 /* Analyze alignment of DRs of stmts in NODE.  */
 
 static bool
-vect_slp_analyze_and_verify_node_alignment (vec_info *vinfo, slp_tree node)
+vect_slp_analyze_node_alignment (vec_info *vinfo, slp_tree node)
 {
   /* We vectorize from the first scalar stmt in the node unless
      the node is permuted in which case we start from the first
@@ -2457,15 +2396,6 @@ vect_slp_analyze_and_verify_node_alignment (vec_info *vinfo, slp_tree node)
        vect_compute_data_ref_alignment (vinfo, first_dr_info);
     }
 
-  if (! verify_data_ref_alignment (vinfo, dr_info))
-    {
-      if (dump_enabled_p ())
-       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                        "not vectorized: bad data alignment in basic "
-                        "block.\n");
-      return false;
-    }
-
   return true;
 }
 
@@ -2475,20 +2405,20 @@ vect_slp_analyze_and_verify_node_alignment (vec_info *vinfo, slp_tree node)
    Return FALSE if a data reference is found that cannot be vectorized.  */
 
 bool
-vect_slp_analyze_and_verify_instance_alignment (vec_info *vinfo,
+vect_slp_analyze_instance_alignment (vec_info *vinfo,
                                                slp_instance instance)
 {
-  DUMP_VECT_SCOPE ("vect_slp_analyze_and_verify_instance_alignment");
+  DUMP_VECT_SCOPE ("vect_slp_analyze_instance_alignment");
 
   slp_tree node;
   unsigned i;
   FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, node)
-    if (! vect_slp_analyze_and_verify_node_alignment (vinfo, node))
+    if (! vect_slp_analyze_node_alignment (vinfo, node))
       return false;
 
   node = SLP_INSTANCE_TREE (instance);
   if (STMT_VINFO_DATA_REF (SLP_TREE_REPRESENTATIVE (node))
-      && ! vect_slp_analyze_and_verify_node_alignment
+      && ! vect_slp_analyze_node_alignment
             (vinfo, SLP_INSTANCE_TREE (instance)))
     return false;
 
index fb56ca48b68c0b83a8e45c7b5e7692b7547bd4bc..6ec16475c6631f83fe03d0ba786f9534987f1c70 100644 (file)
@@ -2136,8 +2136,6 @@ start_over:
     /* This pass will decide on using loop versioning and/or loop peeling in
        order to enhance the alignment of data references in the loop.  */
     ok = vect_enhance_data_refs_alignment (loop_vinfo);
-  else
-    ok = vect_verify_datarefs_alignment (loop_vinfo);
   if (!ok)
     return ok;
 
index 33fc87a9f861d3e92c7f1c8ad5844ee782507ad9..35ae698459349f6125fda75e280d887fec91f055 100644 (file)
@@ -3289,7 +3289,7 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal)
      dependence in the SLP instances.  */
   for (i = 0; BB_VINFO_SLP_INSTANCES (bb_vinfo).iterate (i, &instance); )
     {
-      if (! vect_slp_analyze_and_verify_instance_alignment (bb_vinfo, instance)
+      if (! vect_slp_analyze_instance_alignment (bb_vinfo, instance)
          || ! vect_slp_analyze_instance_dependence (bb_vinfo, instance))
        {
          slp_tree node = SLP_INSTANCE_TREE (instance);
index 5eae74e8042ef53a360145e27c9a0a5e0d2bd980..6730cae8085463cbd57a28b28e52430c1e16e544 100644 (file)
@@ -7190,6 +7190,13 @@ vectorizable_store (vec_info *vinfo,
          return false;
        }
 
+      if (dump_enabled_p ()
+         && memory_access_type != VMAT_ELEMENTWISE
+         && memory_access_type != VMAT_GATHER_SCATTER
+         && alignment_support_scheme != dr_aligned)
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "Vectorizing an unaligned access.\n");
+
       STMT_VINFO_TYPE (stmt_info) = store_vec_info_type;
       vect_model_store_cost (vinfo, stmt_info, ncopies,
                             memory_access_type, vls_type, slp_node, cost_vec);
@@ -8475,6 +8482,13 @@ vectorizable_load (vec_info *vinfo,
                                              group_size, memory_access_type,
                                              &gs_info, mask);
 
+      if (dump_enabled_p ()
+         && memory_access_type != VMAT_ELEMENTWISE
+         && memory_access_type != VMAT_GATHER_SCATTER
+         && alignment_support_scheme != dr_aligned)
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "Vectorizing an unaligned access.\n");
+
       STMT_VINFO_TYPE (orig_stmt_info) = load_vec_info_type;
       vect_model_load_cost (vinfo, stmt_info, ncopies, vf, memory_access_type,
                            slp_node, cost_vec);
index 7c6de8397b38486a4d9ad8ebf24bf958734a062b..91d3291ab566e0d56f439a046cdebb92a0fa48d9 100644 (file)
@@ -1892,9 +1892,7 @@ extern opt_result vect_analyze_data_ref_dependences (loop_vec_info, unsigned int
 extern bool vect_slp_analyze_instance_dependence (vec_info *, slp_instance);
 extern opt_result vect_enhance_data_refs_alignment (loop_vec_info);
 extern opt_result vect_analyze_data_refs_alignment (loop_vec_info);
-extern opt_result vect_verify_datarefs_alignment (loop_vec_info);
-extern bool vect_slp_analyze_and_verify_instance_alignment (vec_info *,
-                                                           slp_instance);
+extern bool vect_slp_analyze_instance_alignment (vec_info *, slp_instance);
 extern opt_result vect_analyze_data_ref_accesses (vec_info *);
 extern opt_result vect_prune_runtime_alias_test_list (loop_vec_info);
 extern bool vect_gather_scatter_fn_p (vec_info *, bool, bool, tree, tree,