The following avoids looking at STMT_VINFO_VECTYPE in
vect_setup_realignment and instead passes down the relevant vector
type.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR tree-optimization/121802
        * tree-vectorizer.h (vect_setup_realignment): Add vectype
        argument.
        * tree-vect-data-refs.cc (vect_setup_realignment): Replace
        local vectype with argument.
        * tree-vect-stmts.cc (vectorizable_load): Adjust.
---
 gcc/tree-vect-data-refs.cc |  3 +--
 gcc/tree-vect-stmts.cc     | 10 +++++-----
 gcc/tree-vectorizer.h      |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index e451b72e07e..a31ff93bbd3 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -6118,13 +6118,12 @@ vect_store_lanes_supported (tree vectype, unsigned 
HOST_WIDE_INT count,
    Return value - the result of the loop-header phi node.  */
 
 tree
-vect_setup_realignment (vec_info *vinfo, stmt_vec_info stmt_info,
+vect_setup_realignment (vec_info *vinfo, stmt_vec_info stmt_info, tree vectype,
                        gimple_stmt_iterator *gsi, tree *realignment_token,
                        enum dr_alignment_support alignment_support_scheme,
                        tree init_addr,
                        class loop **at_loop)
 {
-  tree vectype = STMT_VINFO_VECTYPE (stmt_info);
   loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo);
   dr_vec_info *dr_info = STMT_VINFO_DR_INFO (stmt_info);
   struct data_reference *dr = dr_info->dr;
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 5b1f291fa8d..edc669ba3e4 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -10210,7 +10210,7 @@ vectorizable_load (vec_info *vinfo,
       if (!costing_p)
        {
          if (!diff_first_stmt_info)
-           msq = vect_setup_realignment (vinfo, first_stmt_info, gsi,
+           msq = vect_setup_realignment (vinfo, first_stmt_info, vectype, gsi,
                                          &realignment_token,
                                          alignment_support_scheme, NULL_TREE,
                                          &at_loop);
@@ -10813,8 +10813,8 @@ vectorizable_load (vec_info *vinfo,
                                         stmt_info, diff);
          if (alignment_support_scheme == dr_explicit_realign)
            {
-             msq = vect_setup_realignment (vinfo,
-                                           first_stmt_info_for_drptr, gsi,
+             msq = vect_setup_realignment (vinfo, first_stmt_info_for_drptr,
+                                           vectype, gsi,
                                            &realignment_token,
                                            alignment_support_scheme,
                                            dataref_ptr, &at_loop);
@@ -11167,8 +11167,8 @@ vectorizable_load (vec_info *vinfo,
            tree vs = size_int (TYPE_VECTOR_SUBPARTS (vectype));
 
            if (compute_in_loop)
-             msq = vect_setup_realignment (vinfo, first_stmt_info, gsi,
-                                           &realignment_token,
+             msq = vect_setup_realignment (vinfo, first_stmt_info, vectype,
+                                           gsi, &realignment_token,
                                            dr_explicit_realign,
                                            dataref_ptr, NULL);
 
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 159239fd2f4..749a9830e07 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2647,7 +2647,7 @@ extern bool vect_grouped_load_supported (tree, bool, 
unsigned HOST_WIDE_INT);
 extern internal_fn vect_load_lanes_supported (tree, unsigned HOST_WIDE_INT,
                                              bool, vec<int> * = nullptr);
 extern tree vect_setup_realignment (vec_info *,
-                                   stmt_vec_info, gimple_stmt_iterator *,
+                                   stmt_vec_info, tree, gimple_stmt_iterator *,
                                    tree *, enum dr_alignment_support, tree,
                                    class loop **);
 extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *);
-- 
2.51.0

Reply via email to