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.

I'll see whether to find a suitable machine to test !hw_misalign_supported
(altivec-only ppc I think?  hints welcome...), but maybe I'm lazy...

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2020-07-08  Richard Biener  <rguent...@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/tree-vect-data-refs.c | 88 ++++-----------------------------------
 gcc/tree-vect-loop.c      |  2 -
 gcc/tree-vect-slp.c       |  2 +-
 gcc/tree-vect-stmts.c     | 14 +++++++
 gcc/tree-vectorizer.h     |  4 +-
 5 files changed, 25 insertions(+), 85 deletions(-)

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 2b4421b5fb4..e35a215e042 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -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;
 
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index bc913eeeb36..be01ac81d46 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -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;
 
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 33fc87a9f86..35ae6984593 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -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);
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index cec5c601268..444110f72d0 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -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);
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 7c6de8397b3..91d3291ab56 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -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,
-- 
2.26.2

Reply via email to