https://gcc.gnu.org/g:13beea469554efcffd0f2cda6f0484a603577f27

commit r16-2167-g13beea469554efcffd0f2cda6f0484a603577f27
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Jul 10 10:25:03 2025 +0200

    Avoid vect_is_simple_use call from get_load_store_type
    
    This isn't the required refactoring of vect_check_gather_scatter
    but it avoids a now unnecessary call to vect_is_simple_use which
    is problematic because it looks at STMT_VINFO_VECTYPE which we
    want to get rid of.  SLP build already ensures vect_is_simple_use
    on all lane defs, so all we need is to populate the offset_vectype
    and offset_dt which is not always set by vect_check_gather_scatter.
    That's both easy to get from the SLP child directly.
    
            * tree-vect-stmts.cc (get_load_store_type): Do not use
            vect_is_simple_use to fill gather/scatter offset operand
            vectype and dt.

Diff:
---
 gcc/tree-vect-stmts.cc | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index e5971e4a357b..4aa69da2218b 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -2466,17 +2466,10 @@ get_load_store_type (vec_info  *vinfo, stmt_vec_info 
stmt_info,
                             vls_type == VLS_LOAD ? "gather" : "scatter");
          return false;
        }
-      else if (!vect_is_simple_use (gs_info->offset, vinfo,
-                                   &gs_info->offset_dt,
-                                   &gs_info->offset_vectype))
-       {
-         if (dump_enabled_p ())
-           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                            "%s index use not simple.\n",
-                            vls_type == VLS_LOAD ? "gather" : "scatter");
-         return false;
-       }
-      else if (gs_info->ifn == IFN_LAST && !gs_info->decl)
+      slp_tree offset_node = SLP_TREE_CHILDREN (slp_node)[0];
+      gs_info->offset_dt = SLP_TREE_DEF_TYPE (offset_node);
+      gs_info->offset_vectype = SLP_TREE_VECTYPE (offset_node);
+      if (gs_info->ifn == IFN_LAST && !gs_info->decl)
        {
          if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant ()
              || !TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype).is_constant ()

Reply via email to