https://gcc.gnu.org/g:54edbeeaac6eb4865fab37374fbdff3a9a2f2e12

commit r16-3047-g54edbeeaac6eb4865fab37374fbdff3a9a2f2e12
Author: Richard Biener <rguent...@suse.de>
Date:   Wed Aug 6 09:38:55 2025 +0200

    Simplify vect_supportable_dr_alignment
    
    The following simplifies vect_supportable_dr_alignment based on
    the observation that we always dereference dr_info so it cannot
    be NULL, likewise we always dereference dr so that cannot be NULL
    either.
    
            * tree-vect-data-refs.cc (vect_supportable_dr_alignment):
            Prune dead code.

Diff:
---
 gcc/tree-vect-data-refs.cc | 37 +++----------------------------------
 1 file changed, 3 insertions(+), 34 deletions(-)

diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 4db0ec8abae6..a9d4aaee7718 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -6536,7 +6536,7 @@ vect_supportable_dr_alignment (vec_info *vinfo, 
dr_vec_info *dr_info,
                               tree vectype, int misalignment,
                               gather_scatter_info *gs_info)
 {
-  data_reference *dr = dr_info ? dr_info->dr : nullptr;
+  data_reference *dr = dr_info->dr;
   stmt_vec_info stmt_info = dr_info->stmt;
   machine_mode mode = TYPE_MODE (vectype);
   loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo);
@@ -6617,7 +6617,7 @@ vect_supportable_dr_alignment (vec_info *vinfo, 
dr_vec_info *dr_info,
         }
     } */
 
-  if (dr && DR_IS_READ (dr))
+  if (DR_IS_READ (dr))
     {
       if (can_implement_p (vec_realign_load_optab, mode)
          && (!targetm.vectorize.builtin_mask_for_load
@@ -6647,38 +6647,7 @@ vect_supportable_dr_alignment (vec_info *vinfo, 
dr_vec_info *dr_info,
   tree type = TREE_TYPE (DR_REF (dr));
   bool is_gather_scatter = gs_info != nullptr;
   if (misalignment == DR_MISALIGNMENT_UNKNOWN)
-    {
-      if (!is_gather_scatter || dr != nullptr)
-       is_packed = not_size_aligned (DR_REF (dr));
-      else
-       {
-         /* Gather-scatter accesses normally perform only component accesses
-            so alignment is irrelevant for them.  Targets like riscv do care
-            about scalar alignment in vector accesses, though, so check scalar
-            alignment here.  We determined the alias pointer as well as the
-            base alignment during pattern recognition and can re-use it here.
-
-            As we do not have an analyzed dataref we only know the alignment
-            of the reference itself and nothing about init, steps, etc.
-            For now don't try harder to determine misalignment and
-            just assume it is unknown.  We consider the type packed if its
-            scalar alignment is lower than the natural alignment of a vector
-            element's type.  */
-
-         gcc_assert (!GATHER_SCATTER_LEGACY_P (*gs_info));
-         gcc_assert (dr == nullptr);
-
-         tree inner_vectype = TREE_TYPE (vectype);
-
-         unsigned HOST_WIDE_INT scalar_align
-           = tree_to_uhwi (gs_info->alias_ptr);
-         unsigned HOST_WIDE_INT inner_vectype_sz
-           = tree_to_uhwi (TYPE_SIZE (inner_vectype));
-
-         bool is_misaligned = scalar_align < inner_vectype_sz;
-         is_packed = scalar_align > 1 && is_misaligned;
-       }
-    }
+    is_packed = not_size_aligned (DR_REF (dr));
   if (targetm.vectorize.support_vector_misalignment (mode, type, misalignment,
                                                     is_packed,
                                                     is_gather_scatter))

Reply via email to