[06/46] Add vec_info::add_stmt

Message ID 877ellrmab.fsf@arm.com
State New
Headers show
Series
  • Remove vinfo_for_stmt etc.
Related show

Commit Message

Richard Sandiford July 24, 2018, 9:54 a.m.
This patch adds a vec_info function for allocating and setting
stmt_vec_infos.  It's the start of a long process of removing
the global stmt_vec_info array.


2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vectorizer.h (stmt_vec_info): Move typedef earlier in file.
	(vec_info::add_stmt): Declare.
	* tree-vectorizer.c (vec_info::add_stmt): New function.
	* tree-vect-data-refs.c (vect_create_data_ref_ptr): Use it.
	* tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Likewise.
	(vect_create_epilog_for_reduction, vectorizable_reduction): Likewise.
	(vectorizable_induction): Likewise.
	* tree-vect-slp.c (_bb_vec_info::_bb_vec_info): Likewise.
	* tree-vect-stmts.c (vect_finish_stmt_generation_1): Likewise.
	(vectorizable_simd_clone_call, vectorizable_store): Likewise.
	(vectorizable_load): Likewise.
	* tree-vect-patterns.c (vect_init_pattern_stmt): Likewise.
	(vect_recog_bool_pattern, vect_recog_mask_conversion_pattern)
	(vect_recog_gather_scatter_pattern): Likewise.
	(append_pattern_def_seq): Likewise.  Remove a check that is
	performed by add_stmt itself.

Comments

Richard Biener July 25, 2018, 9:09 a.m. | #1
On Tue, Jul 24, 2018 at 11:55 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>

> This patch adds a vec_info function for allocating and setting

> stmt_vec_infos.  It's the start of a long process of removing

> the global stmt_vec_info array.

>

>

> 2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

>

> gcc/

>         * tree-vectorizer.h (stmt_vec_info): Move typedef earlier in file.

>         (vec_info::add_stmt): Declare.

>         * tree-vectorizer.c (vec_info::add_stmt): New function.

>         * tree-vect-data-refs.c (vect_create_data_ref_ptr): Use it.

>         * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Likewise.

>         (vect_create_epilog_for_reduction, vectorizable_reduction): Likewise.

>         (vectorizable_induction): Likewise.

>         * tree-vect-slp.c (_bb_vec_info::_bb_vec_info): Likewise.

>         * tree-vect-stmts.c (vect_finish_stmt_generation_1): Likewise.

>         (vectorizable_simd_clone_call, vectorizable_store): Likewise.

>         (vectorizable_load): Likewise.

>         * tree-vect-patterns.c (vect_init_pattern_stmt): Likewise.

>         (vect_recog_bool_pattern, vect_recog_mask_conversion_pattern)

>         (vect_recog_gather_scatter_pattern): Likewise.

>         (append_pattern_def_seq): Likewise.  Remove a check that is

>         performed by add_stmt itself.

>

> Index: gcc/tree-vectorizer.h

> ===================================================================

> --- gcc/tree-vectorizer.h       2018-07-24 10:22:09.237496975 +0100

> +++ gcc/tree-vectorizer.h       2018-07-24 10:22:19.809403100 +0100

> @@ -25,6 +25,8 @@ #define GCC_TREE_VECTORIZER_H

>  #include "tree-hash-traits.h"

>  #include "target.h"

>

> +typedef struct _stmt_vec_info *stmt_vec_info;

> +

>  /* Used for naming of new temporaries.  */

>  enum vect_var_kind {

>    vect_simple_var,

> @@ -215,6 +217,8 @@ struct vec_info {

>    vec_info (vec_kind, void *, vec_info_shared *);

>    ~vec_info ();

>

> +  stmt_vec_info add_stmt (gimple *);

> +

>    /* The type of vectorization.  */

>    vec_kind kind;

>

> @@ -761,7 +765,7 @@ struct dataref_aux {

>

>  typedef struct data_reference *dr_p;

>

> -typedef struct _stmt_vec_info {

> +struct _stmt_vec_info {

>

>    enum stmt_vec_info_type type;

>

> @@ -914,7 +918,7 @@ typedef struct _stmt_vec_info {

>       and OPERATION_BITS without changing the result.  */

>    unsigned int operation_precision;

>    signop operation_sign;

> -} *stmt_vec_info;

> +};

>

>  /* Information about a gather/scatter call.  */

>  struct gather_scatter_info {

> Index: gcc/tree-vectorizer.c

> ===================================================================

> --- gcc/tree-vectorizer.c       2018-07-24 10:22:09.237496975 +0100

> +++ gcc/tree-vectorizer.c       2018-07-24 10:22:19.809403100 +0100

> @@ -507,6 +507,17 @@ vec_info_shared::check_datarefs ()

>        gcc_unreachable ();

>  }

>

> +/* Record that STMT belongs to the vectorizable region.  Create and return

> +   an associated stmt_vec_info.  */

> +

> +stmt_vec_info

> +vec_info::add_stmt (gimple *stmt)

> +{

> +  stmt_vec_info res = new_stmt_vec_info (stmt, this);

> +  set_vinfo_for_stmt (stmt, res);


are these now the only callers?

OK.

> +  return res;

> +}

> +

>  /* A helper function to free scev and LOOP niter information, as well as

>     clear loop constraint LOOP_C_FINITE.  */

>

> Index: gcc/tree-vect-data-refs.c

> ===================================================================

> --- gcc/tree-vect-data-refs.c   2018-07-23 15:56:47.000000000 +0100

> +++ gcc/tree-vect-data-refs.c   2018-07-24 10:22:19.801403171 +0100

> @@ -4850,7 +4850,7 @@ vect_create_data_ref_ptr (gimple *stmt,

>                  aggr_ptr, loop, &incr_gsi, insert_after,

>                  &indx_before_incr, &indx_after_incr);

>        incr = gsi_stmt (incr_gsi);

> -      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));

> +      loop_vinfo->add_stmt (incr);

>

>        /* Copy the points-to information if it exists. */

>        if (DR_PTR_INFO (dr))

> @@ -4880,7 +4880,7 @@ vect_create_data_ref_ptr (gimple *stmt,

>                  containing_loop, &incr_gsi, insert_after, &indx_before_incr,

>                  &indx_after_incr);

>        incr = gsi_stmt (incr_gsi);

> -      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));

> +      loop_vinfo->add_stmt (incr);

>

>        /* Copy the points-to information if it exists. */

>        if (DR_PTR_INFO (dr))

> Index: gcc/tree-vect-loop.c

> ===================================================================

> --- gcc/tree-vect-loop.c        2018-07-24 10:22:16.421433184 +0100

> +++ gcc/tree-vect-loop.c        2018-07-24 10:22:19.801403171 +0100

> @@ -845,14 +845,14 @@ _loop_vec_info::_loop_vec_info (struct l

>         {

>           gimple *phi = gsi_stmt (si);

>           gimple_set_uid (phi, 0);

> -         set_vinfo_for_stmt (phi, new_stmt_vec_info (phi, this));

> +         add_stmt (phi);

>         }

>

>        for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))

>         {

>           gimple *stmt = gsi_stmt (si);

>           gimple_set_uid (stmt, 0);

> -         set_vinfo_for_stmt (stmt, new_stmt_vec_info (stmt, this));

> +         add_stmt (stmt);

>         }

>      }

>    free (body);

> @@ -4665,8 +4665,7 @@ vect_create_epilog_for_reduction (vec<tr

>        /* Create a vector phi node.  */

>        tree new_phi_tree = make_ssa_name (cr_index_vector_type);

>        new_phi = create_phi_node (new_phi_tree, loop->header);

> -      set_vinfo_for_stmt (new_phi,

> -                         new_stmt_vec_info (new_phi, loop_vinfo));

> +      loop_vinfo->add_stmt (new_phi);

>        add_phi_arg (as_a <gphi *> (new_phi), vec_zero,

>                    loop_preheader_edge (loop), UNKNOWN_LOCATION);

>

> @@ -4691,10 +4690,8 @@ vect_create_epilog_for_reduction (vec<tr

>        gimple *index_condition = gimple_build_assign (induction_index,

>                                                      index_cond_expr);

>        gsi_insert_before (&incr_gsi, index_condition, GSI_SAME_STMT);

> -      stmt_vec_info index_vec_info = new_stmt_vec_info (index_condition,

> -                                                       loop_vinfo);

> +      stmt_vec_info index_vec_info = loop_vinfo->add_stmt (index_condition);

>        STMT_VINFO_VECTYPE (index_vec_info) = cr_index_vector_type;

> -      set_vinfo_for_stmt (index_condition, index_vec_info);

>

>        /* Update the phi with the vec cond.  */

>        add_phi_arg (as_a <gphi *> (new_phi), induction_index,

> @@ -4741,7 +4738,7 @@ vect_create_epilog_for_reduction (vec<tr

>          {

>           tree new_def = copy_ssa_name (def);

>            phi = create_phi_node (new_def, exit_bb);

> -          set_vinfo_for_stmt (phi, new_stmt_vec_info (phi, loop_vinfo));

> +         stmt_vec_info phi_info = loop_vinfo->add_stmt (phi);

>            if (j == 0)

>              new_phis.quick_push (phi);

>            else

> @@ -4751,7 +4748,7 @@ vect_create_epilog_for_reduction (vec<tr

>             }

>

>            SET_PHI_ARG_DEF (phi, single_exit (loop)->dest_idx, def);

> -          prev_phi_info = vinfo_for_stmt (phi);

> +         prev_phi_info = phi_info;

>          }

>      }

>

> @@ -4768,11 +4765,9 @@ vect_create_epilog_for_reduction (vec<tr

>           gphi *outer_phi = create_phi_node (new_result, exit_bb);

>           SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,

>                            PHI_RESULT (phi));

> -         set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,

> -                                                           loop_vinfo));

> +         prev_phi_info = loop_vinfo->add_stmt (outer_phi);

>           inner_phis.quick_push (phi);

>           new_phis[i] = outer_phi;

> -         prev_phi_info = vinfo_for_stmt (outer_phi);

>            while (STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi)))

>              {

>               phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi));

> @@ -4780,10 +4775,9 @@ vect_create_epilog_for_reduction (vec<tr

>               outer_phi = create_phi_node (new_result, exit_bb);

>               SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,

>                                PHI_RESULT (phi));

> -             set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,

> -                                                               loop_vinfo));

> +             stmt_vec_info outer_phi_info = loop_vinfo->add_stmt (outer_phi);

>               STMT_VINFO_RELATED_STMT (prev_phi_info) = outer_phi;

> -             prev_phi_info = vinfo_for_stmt (outer_phi);

> +             prev_phi_info = outer_phi_info;

>             }

>         }

>      }

> @@ -5553,10 +5547,9 @@ vect_create_epilog_for_reduction (vec<tr

>        gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);

>        if (nested_in_vect_loop)

>          {

> -          set_vinfo_for_stmt (epilog_stmt,

> -                              new_stmt_vec_info (epilog_stmt, loop_vinfo));

> -          STMT_VINFO_RELATED_STMT (vinfo_for_stmt (epilog_stmt)) =

> -                STMT_VINFO_RELATED_STMT (vinfo_for_stmt (new_phi));

> +         stmt_vec_info epilog_stmt_info = loop_vinfo->add_stmt (epilog_stmt);

> +         STMT_VINFO_RELATED_STMT (epilog_stmt_info)

> +           = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (new_phi));

>

>            if (!double_reduc)

>              scalar_results.quick_push (new_temp);

> @@ -5697,7 +5690,6 @@ vect_create_epilog_for_reduction (vec<tr

>                FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, orig_name)

>                  {

>                    stmt_vec_info use_stmt_vinfo;

> -                  stmt_vec_info new_phi_vinfo;

>                    tree vect_phi_init, preheader_arg, vect_phi_res;

>                    basic_block bb = gimple_bb (use_stmt);

>                   gimple *use;

> @@ -5724,9 +5716,7 @@ vect_create_epilog_for_reduction (vec<tr

>

>                    /* Create vector phi node.  */

>                    vect_phi = create_phi_node (vec_initial_def, bb);

> -                  new_phi_vinfo = new_stmt_vec_info (vect_phi,

> -                                    loop_vec_info_for_loop (outer_loop));

> -                  set_vinfo_for_stmt (vect_phi, new_phi_vinfo);

> +                 loop_vec_info_for_loop (outer_loop)->add_stmt (vect_phi);

>

>                    /* Create vs0 - initial def of the double reduction phi.  */

>                    preheader_arg = PHI_ARG_DEF_FROM_EDGE (use_stmt,

> @@ -6249,8 +6239,7 @@ vectorizable_reduction (gimple *stmt, gi

>                   /* Create the reduction-phi that defines the reduction

>                      operand.  */

>                   gimple *new_phi = create_phi_node (vec_dest, loop->header);

> -                 set_vinfo_for_stmt (new_phi,

> -                                     new_stmt_vec_info (new_phi, loop_vinfo));

> +                 stmt_vec_info new_phi_info = loop_vinfo->add_stmt (new_phi);

>

>                   if (slp_node)

>                     SLP_TREE_VEC_STMTS (slp_node).quick_push (new_phi);

> @@ -6260,7 +6249,7 @@ vectorizable_reduction (gimple *stmt, gi

>                         STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_phi;

>                       else

>                         STMT_VINFO_RELATED_STMT (prev_phi_info) = new_phi;

> -                     prev_phi_info = vinfo_for_stmt (new_phi);

> +                     prev_phi_info = new_phi_info;

>                     }

>                 }

>             }

> @@ -7537,15 +7526,14 @@ vectorizable_induction (gimple *phi,

>           /* Create the induction-phi that defines the induction-operand.  */

>           vec_dest = vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_");

>           induction_phi = create_phi_node (vec_dest, iv_loop->header);

> -         set_vinfo_for_stmt (induction_phi,

> -                             new_stmt_vec_info (induction_phi, loop_vinfo));

> +         loop_vinfo->add_stmt (induction_phi);

>           induc_def = PHI_RESULT (induction_phi);

>

>           /* Create the iv update inside the loop  */

>           vec_def = make_ssa_name (vec_dest);

>           new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step);

>           gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);

> -         set_vinfo_for_stmt (new_stmt, new_stmt_vec_info (new_stmt, loop_vinfo));

> +         loop_vinfo->add_stmt (new_stmt);

>

>           /* Set the arguments of the phi node:  */

>           add_phi_arg (induction_phi, vec_init, pe, UNKNOWN_LOCATION);

> @@ -7593,8 +7581,7 @@ vectorizable_induction (gimple *phi,

>                   gimple_stmt_iterator tgsi = gsi_for_stmt (iv);

>                   gsi_insert_after (&tgsi, new_stmt, GSI_CONTINUE_LINKING);

>                 }

> -             set_vinfo_for_stmt (new_stmt,

> -                                 new_stmt_vec_info (new_stmt, loop_vinfo));

> +             loop_vinfo->add_stmt (new_stmt);

>               SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);

>             }

>         }

> @@ -7623,8 +7610,7 @@ vectorizable_induction (gimple *phi,

>           new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop),

>                                                  new_stmt);

>           gcc_assert (!new_bb);

> -         set_vinfo_for_stmt (new_stmt,

> -                             new_stmt_vec_info (new_stmt, loop_vinfo));

> +         loop_vinfo->add_stmt (new_stmt);

>         }

>      }

>    else

> @@ -7728,15 +7714,14 @@ vectorizable_induction (gimple *phi,

>    /* Create the induction-phi that defines the induction-operand.  */

>    vec_dest = vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_");

>    induction_phi = create_phi_node (vec_dest, iv_loop->header);

> -  set_vinfo_for_stmt (induction_phi,

> -                     new_stmt_vec_info (induction_phi, loop_vinfo));

> +  stmt_vec_info induction_phi_info = loop_vinfo->add_stmt (induction_phi);

>    induc_def = PHI_RESULT (induction_phi);

>

>    /* Create the iv update inside the loop  */

>    vec_def = make_ssa_name (vec_dest);

>    new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step);

>    gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);

> -  set_vinfo_for_stmt (new_stmt, new_stmt_vec_info (new_stmt, loop_vinfo));

> +  stmt_vec_info new_stmt_info = loop_vinfo->add_stmt (new_stmt);

>

>    /* Set the arguments of the phi node:  */

>    add_phi_arg (induction_phi, vec_init, pe, UNKNOWN_LOCATION);

> @@ -7781,7 +7766,7 @@ vectorizable_induction (gimple *phi,

>        vec_step = vect_init_vector (phi, new_vec, vectype, NULL);

>

>        vec_def = induc_def;

> -      prev_stmt_vinfo = vinfo_for_stmt (induction_phi);

> +      prev_stmt_vinfo = induction_phi_info;

>        for (i = 1; i < ncopies; i++)

>         {

>           /* vec_i = vec_prev + vec_step  */

> @@ -7791,10 +7776,9 @@ vectorizable_induction (gimple *phi,

>           gimple_assign_set_lhs (new_stmt, vec_def);

>

>           gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);

> -         set_vinfo_for_stmt (new_stmt,

> -                             new_stmt_vec_info (new_stmt, loop_vinfo));

> +         new_stmt_info = loop_vinfo->add_stmt (new_stmt);

>           STMT_VINFO_RELATED_STMT (prev_stmt_vinfo) = new_stmt;

> -         prev_stmt_vinfo = vinfo_for_stmt (new_stmt);

> +         prev_stmt_vinfo = new_stmt_info;

>         }

>      }

>

> Index: gcc/tree-vect-slp.c

> ===================================================================

> --- gcc/tree-vect-slp.c 2018-07-24 10:22:09.237496975 +0100

> +++ gcc/tree-vect-slp.c 2018-07-24 10:22:19.805403136 +0100

> @@ -2494,7 +2494,7 @@ _bb_vec_info::_bb_vec_info (gimple_stmt_

>      {

>        gimple *stmt = gsi_stmt (gsi);

>        gimple_set_uid (stmt, 0);

> -      set_vinfo_for_stmt (stmt, new_stmt_vec_info (stmt, this));

> +      add_stmt (stmt);

>      }

>

>    bb->aux = this;

> Index: gcc/tree-vect-stmts.c

> ===================================================================

> --- gcc/tree-vect-stmts.c       2018-07-13 10:11:14.533842692 +0100

> +++ gcc/tree-vect-stmts.c       2018-07-24 10:22:19.809403100 +0100

> @@ -1744,7 +1744,7 @@ vect_finish_stmt_generation_1 (gimple *s

>    stmt_vec_info stmt_info = vinfo_for_stmt (stmt);

>    vec_info *vinfo = stmt_info->vinfo;

>

> -  set_vinfo_for_stmt (vec_stmt, new_stmt_vec_info (vec_stmt, vinfo));

> +  vinfo->add_stmt (vec_stmt);

>

>    if (dump_enabled_p ())

>      {

> @@ -4183,8 +4183,7 @@ vectorizable_simd_clone_call (gimple *st

>                     }

>                   tree phi_res = copy_ssa_name (op);

>                   gphi *new_phi = create_phi_node (phi_res, loop->header);

> -                 set_vinfo_for_stmt (new_phi,

> -                                     new_stmt_vec_info (new_phi, loop_vinfo));

> +                 loop_vinfo->add_stmt (new_phi);

>                   add_phi_arg (new_phi, arginfo[i].op,

>                                loop_preheader_edge (loop), UNKNOWN_LOCATION);

>                   enum tree_code code

> @@ -4201,8 +4200,7 @@ vectorizable_simd_clone_call (gimple *st

>                     = gimple_build_assign (phi_arg, code, phi_res, tcst);

>                   gimple_stmt_iterator si = gsi_after_labels (loop->header);

>                   gsi_insert_after (&si, new_stmt, GSI_NEW_STMT);

> -                 set_vinfo_for_stmt (new_stmt,

> -                                     new_stmt_vec_info (new_stmt, loop_vinfo));

> +                 loop_vinfo->add_stmt (new_stmt);

>                   add_phi_arg (new_phi, phi_arg, loop_latch_edge (loop),

>                                UNKNOWN_LOCATION);

>                   arginfo[i].op = phi_res;

> @@ -6731,7 +6729,7 @@ vectorizable_store (gimple *stmt, gimple

>                  loop, &incr_gsi, insert_after,

>                  &offvar, NULL);

>        incr = gsi_stmt (incr_gsi);

> -      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));

> +      loop_vinfo->add_stmt (incr);

>

>        stride_step = cse_and_gimplify_to_preheader (loop_vinfo, stride_step);

>

> @@ -7729,7 +7727,7 @@ vectorizable_load (gimple *stmt, gimple_

>                  loop, &incr_gsi, insert_after,

>                  &offvar, NULL);

>        incr = gsi_stmt (incr_gsi);

> -      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));

> +      loop_vinfo->add_stmt (incr);

>

>        stride_step = cse_and_gimplify_to_preheader (loop_vinfo, stride_step);

>

> @@ -8488,8 +8486,7 @@ vectorizable_load (gimple *stmt, gimple_

>                                                 (gimple_assign_rhs1 (stmt))));

>                       new_temp = vect_init_vector (stmt, tem, vectype, NULL);

>                       new_stmt = SSA_NAME_DEF_STMT (new_temp);

> -                     set_vinfo_for_stmt (new_stmt,

> -                                         new_stmt_vec_info (new_stmt, vinfo));

> +                     vinfo->add_stmt (new_stmt);

>                     }

>                   else

>                     {

> Index: gcc/tree-vect-patterns.c

> ===================================================================

> --- gcc/tree-vect-patterns.c    2018-07-18 18:44:23.517905682 +0100

> +++ gcc/tree-vect-patterns.c    2018-07-24 10:22:19.805403136 +0100

> @@ -103,11 +103,7 @@ vect_init_pattern_stmt (gimple *pattern_

>  {

>    stmt_vec_info pattern_stmt_info = vinfo_for_stmt (pattern_stmt);

>    if (pattern_stmt_info == NULL)

> -    {

> -      pattern_stmt_info = new_stmt_vec_info (pattern_stmt,

> -                                            orig_stmt_info->vinfo);

> -      set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);

> -    }

> +    pattern_stmt_info = orig_stmt_info->vinfo->add_stmt (pattern_stmt);

>    gimple_set_bb (pattern_stmt, gimple_bb (orig_stmt_info->stmt));

>

>    STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info->stmt;

> @@ -141,9 +137,7 @@ append_pattern_def_seq (stmt_vec_info st

>    vec_info *vinfo = stmt_info->vinfo;

>    if (vectype)

>      {

> -      gcc_assert (!vinfo_for_stmt (new_stmt));

> -      stmt_vec_info new_stmt_info = new_stmt_vec_info (new_stmt, vinfo);

> -      set_vinfo_for_stmt (new_stmt, new_stmt_info);

> +      stmt_vec_info new_stmt_info = vinfo->add_stmt (new_stmt);

>        STMT_VINFO_VECTYPE (new_stmt_info) = vectype;

>      }

>    gimple_seq_add_stmt_without_update (&STMT_VINFO_PATTERN_DEF_SEQ (stmt_info),

> @@ -3832,8 +3826,7 @@ vect_recog_bool_pattern (stmt_vec_info s

>           rhs = rhs2;

>         }

>        pattern_stmt = gimple_build_assign (lhs, SSA_NAME, rhs);

> -      pattern_stmt_info = new_stmt_vec_info (pattern_stmt, vinfo);

> -      set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);

> +      pattern_stmt_info = vinfo->add_stmt (pattern_stmt);

>        STMT_VINFO_DATA_REF (pattern_stmt_info)

>         = STMT_VINFO_DATA_REF (stmt_vinfo);

>        STMT_VINFO_DR_WRT_VEC_LOOP (pattern_stmt_info)

> @@ -3958,8 +3951,7 @@ vect_recog_mask_conversion_pattern (stmt

>         }

>        gimple_call_set_nothrow (pattern_stmt, true);

>

> -      pattern_stmt_info = new_stmt_vec_info (pattern_stmt, vinfo);

> -      set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);

> +      pattern_stmt_info = vinfo->add_stmt (pattern_stmt);

>        if (STMT_VINFO_DATA_REF (stmt_vinfo))

>         {

>           STMT_VINFO_DATA_REF (pattern_stmt_info)

> @@ -4290,9 +4282,7 @@ vect_recog_gather_scatter_pattern (stmt_

>

>    /* Copy across relevant vectorization info and associate DR with the

>       new pattern statement instead of the original statement.  */

> -  stmt_vec_info pattern_stmt_info = new_stmt_vec_info (pattern_stmt,

> -                                                      loop_vinfo);

> -  set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);

> +  stmt_vec_info pattern_stmt_info = loop_vinfo->add_stmt (pattern_stmt);

>    STMT_VINFO_DATA_REF (pattern_stmt_info) = dr;

>    STMT_VINFO_DR_WRT_VEC_LOOP (pattern_stmt_info)

>      = STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info);

Patch

Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h	2018-07-24 10:22:09.237496975 +0100
+++ gcc/tree-vectorizer.h	2018-07-24 10:22:19.809403100 +0100
@@ -25,6 +25,8 @@  #define GCC_TREE_VECTORIZER_H
 #include "tree-hash-traits.h"
 #include "target.h"
 
+typedef struct _stmt_vec_info *stmt_vec_info;
+
 /* Used for naming of new temporaries.  */
 enum vect_var_kind {
   vect_simple_var,
@@ -215,6 +217,8 @@  struct vec_info {
   vec_info (vec_kind, void *, vec_info_shared *);
   ~vec_info ();
 
+  stmt_vec_info add_stmt (gimple *);
+
   /* The type of vectorization.  */
   vec_kind kind;
 
@@ -761,7 +765,7 @@  struct dataref_aux {
 
 typedef struct data_reference *dr_p;
 
-typedef struct _stmt_vec_info {
+struct _stmt_vec_info {
 
   enum stmt_vec_info_type type;
 
@@ -914,7 +918,7 @@  typedef struct _stmt_vec_info {
      and OPERATION_BITS without changing the result.  */
   unsigned int operation_precision;
   signop operation_sign;
-} *stmt_vec_info;
+};
 
 /* Information about a gather/scatter call.  */
 struct gather_scatter_info {
Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	2018-07-24 10:22:09.237496975 +0100
+++ gcc/tree-vectorizer.c	2018-07-24 10:22:19.809403100 +0100
@@ -507,6 +507,17 @@  vec_info_shared::check_datarefs ()
       gcc_unreachable ();
 }
 
+/* Record that STMT belongs to the vectorizable region.  Create and return
+   an associated stmt_vec_info.  */
+
+stmt_vec_info
+vec_info::add_stmt (gimple *stmt)
+{
+  stmt_vec_info res = new_stmt_vec_info (stmt, this);
+  set_vinfo_for_stmt (stmt, res);
+  return res;
+}
+
 /* A helper function to free scev and LOOP niter information, as well as
    clear loop constraint LOOP_C_FINITE.  */
 
Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	2018-07-23 15:56:47.000000000 +0100
+++ gcc/tree-vect-data-refs.c	2018-07-24 10:22:19.801403171 +0100
@@ -4850,7 +4850,7 @@  vect_create_data_ref_ptr (gimple *stmt,
 		 aggr_ptr, loop, &incr_gsi, insert_after,
 		 &indx_before_incr, &indx_after_incr);
       incr = gsi_stmt (incr_gsi);
-      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));
+      loop_vinfo->add_stmt (incr);
 
       /* Copy the points-to information if it exists. */
       if (DR_PTR_INFO (dr))
@@ -4880,7 +4880,7 @@  vect_create_data_ref_ptr (gimple *stmt,
 		 containing_loop, &incr_gsi, insert_after, &indx_before_incr,
 		 &indx_after_incr);
       incr = gsi_stmt (incr_gsi);
-      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));
+      loop_vinfo->add_stmt (incr);
 
       /* Copy the points-to information if it exists. */
       if (DR_PTR_INFO (dr))
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	2018-07-24 10:22:16.421433184 +0100
+++ gcc/tree-vect-loop.c	2018-07-24 10:22:19.801403171 +0100
@@ -845,14 +845,14 @@  _loop_vec_info::_loop_vec_info (struct l
 	{
 	  gimple *phi = gsi_stmt (si);
 	  gimple_set_uid (phi, 0);
-	  set_vinfo_for_stmt (phi, new_stmt_vec_info (phi, this));
+	  add_stmt (phi);
 	}
 
       for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
 	{
 	  gimple *stmt = gsi_stmt (si);
 	  gimple_set_uid (stmt, 0);
-	  set_vinfo_for_stmt (stmt, new_stmt_vec_info (stmt, this));
+	  add_stmt (stmt);
 	}
     }
   free (body);
@@ -4665,8 +4665,7 @@  vect_create_epilog_for_reduction (vec<tr
       /* Create a vector phi node.  */
       tree new_phi_tree = make_ssa_name (cr_index_vector_type);
       new_phi = create_phi_node (new_phi_tree, loop->header);
-      set_vinfo_for_stmt (new_phi,
-			  new_stmt_vec_info (new_phi, loop_vinfo));
+      loop_vinfo->add_stmt (new_phi);
       add_phi_arg (as_a <gphi *> (new_phi), vec_zero,
 		   loop_preheader_edge (loop), UNKNOWN_LOCATION);
 
@@ -4691,10 +4690,8 @@  vect_create_epilog_for_reduction (vec<tr
       gimple *index_condition = gimple_build_assign (induction_index,
 						     index_cond_expr);
       gsi_insert_before (&incr_gsi, index_condition, GSI_SAME_STMT);
-      stmt_vec_info index_vec_info = new_stmt_vec_info (index_condition,
-							loop_vinfo);
+      stmt_vec_info index_vec_info = loop_vinfo->add_stmt (index_condition);
       STMT_VINFO_VECTYPE (index_vec_info) = cr_index_vector_type;
-      set_vinfo_for_stmt (index_condition, index_vec_info);
 
       /* Update the phi with the vec cond.  */
       add_phi_arg (as_a <gphi *> (new_phi), induction_index,
@@ -4741,7 +4738,7 @@  vect_create_epilog_for_reduction (vec<tr
         {
 	  tree new_def = copy_ssa_name (def);
           phi = create_phi_node (new_def, exit_bb);
-          set_vinfo_for_stmt (phi, new_stmt_vec_info (phi, loop_vinfo));
+	  stmt_vec_info phi_info = loop_vinfo->add_stmt (phi);
           if (j == 0)
             new_phis.quick_push (phi);
           else
@@ -4751,7 +4748,7 @@  vect_create_epilog_for_reduction (vec<tr
 	    }
 
           SET_PHI_ARG_DEF (phi, single_exit (loop)->dest_idx, def);
-          prev_phi_info = vinfo_for_stmt (phi);
+	  prev_phi_info = phi_info;
         }
     }
 
@@ -4768,11 +4765,9 @@  vect_create_epilog_for_reduction (vec<tr
 	  gphi *outer_phi = create_phi_node (new_result, exit_bb);
 	  SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,
 			   PHI_RESULT (phi));
-	  set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,
-							    loop_vinfo));
+	  prev_phi_info = loop_vinfo->add_stmt (outer_phi);
 	  inner_phis.quick_push (phi);
 	  new_phis[i] = outer_phi;
-	  prev_phi_info = vinfo_for_stmt (outer_phi);
           while (STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi)))
             {
 	      phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi));
@@ -4780,10 +4775,9 @@  vect_create_epilog_for_reduction (vec<tr
 	      outer_phi = create_phi_node (new_result, exit_bb);
 	      SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,
 			       PHI_RESULT (phi));
-	      set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,
-								loop_vinfo));
+	      stmt_vec_info outer_phi_info = loop_vinfo->add_stmt (outer_phi);
 	      STMT_VINFO_RELATED_STMT (prev_phi_info) = outer_phi;
-	      prev_phi_info = vinfo_for_stmt (outer_phi);
+	      prev_phi_info = outer_phi_info;
 	    }
 	}
     }
@@ -5553,10 +5547,9 @@  vect_create_epilog_for_reduction (vec<tr
       gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);
       if (nested_in_vect_loop)
         {
-          set_vinfo_for_stmt (epilog_stmt,
-                              new_stmt_vec_info (epilog_stmt, loop_vinfo));
-          STMT_VINFO_RELATED_STMT (vinfo_for_stmt (epilog_stmt)) =
-                STMT_VINFO_RELATED_STMT (vinfo_for_stmt (new_phi));
+	  stmt_vec_info epilog_stmt_info = loop_vinfo->add_stmt (epilog_stmt);
+	  STMT_VINFO_RELATED_STMT (epilog_stmt_info)
+	    = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (new_phi));
 
           if (!double_reduc)
             scalar_results.quick_push (new_temp);
@@ -5697,7 +5690,6 @@  vect_create_epilog_for_reduction (vec<tr
               FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, orig_name)
                 {
                   stmt_vec_info use_stmt_vinfo;
-                  stmt_vec_info new_phi_vinfo;
                   tree vect_phi_init, preheader_arg, vect_phi_res;
                   basic_block bb = gimple_bb (use_stmt);
 		  gimple *use;
@@ -5724,9 +5716,7 @@  vect_create_epilog_for_reduction (vec<tr
 
                   /* Create vector phi node.  */
                   vect_phi = create_phi_node (vec_initial_def, bb);
-                  new_phi_vinfo = new_stmt_vec_info (vect_phi,
-                                    loop_vec_info_for_loop (outer_loop));
-                  set_vinfo_for_stmt (vect_phi, new_phi_vinfo);
+		  loop_vec_info_for_loop (outer_loop)->add_stmt (vect_phi);
 
                   /* Create vs0 - initial def of the double reduction phi.  */
                   preheader_arg = PHI_ARG_DEF_FROM_EDGE (use_stmt,
@@ -6249,8 +6239,7 @@  vectorizable_reduction (gimple *stmt, gi
 		  /* Create the reduction-phi that defines the reduction
 		     operand.  */
 		  gimple *new_phi = create_phi_node (vec_dest, loop->header);
-		  set_vinfo_for_stmt (new_phi,
-				      new_stmt_vec_info (new_phi, loop_vinfo));
+		  stmt_vec_info new_phi_info = loop_vinfo->add_stmt (new_phi);
 
 		  if (slp_node)
 		    SLP_TREE_VEC_STMTS (slp_node).quick_push (new_phi);
@@ -6260,7 +6249,7 @@  vectorizable_reduction (gimple *stmt, gi
 			STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_phi;
 		      else
 			STMT_VINFO_RELATED_STMT (prev_phi_info) = new_phi;
-		      prev_phi_info = vinfo_for_stmt (new_phi);
+		      prev_phi_info = new_phi_info;
 		    }
 		}
 	    }
@@ -7537,15 +7526,14 @@  vectorizable_induction (gimple *phi,
 	  /* Create the induction-phi that defines the induction-operand.  */
 	  vec_dest = vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_");
 	  induction_phi = create_phi_node (vec_dest, iv_loop->header);
-	  set_vinfo_for_stmt (induction_phi,
-			      new_stmt_vec_info (induction_phi, loop_vinfo));
+	  loop_vinfo->add_stmt (induction_phi);
 	  induc_def = PHI_RESULT (induction_phi);
 
 	  /* Create the iv update inside the loop  */
 	  vec_def = make_ssa_name (vec_dest);
 	  new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step);
 	  gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
-	  set_vinfo_for_stmt (new_stmt, new_stmt_vec_info (new_stmt, loop_vinfo));
+	  loop_vinfo->add_stmt (new_stmt);
 
 	  /* Set the arguments of the phi node:  */
 	  add_phi_arg (induction_phi, vec_init, pe, UNKNOWN_LOCATION);
@@ -7593,8 +7581,7 @@  vectorizable_induction (gimple *phi,
 		  gimple_stmt_iterator tgsi = gsi_for_stmt (iv);
 		  gsi_insert_after (&tgsi, new_stmt, GSI_CONTINUE_LINKING);
 		}
-	      set_vinfo_for_stmt (new_stmt,
-				  new_stmt_vec_info (new_stmt, loop_vinfo));
+	      loop_vinfo->add_stmt (new_stmt);
 	      SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
 	    }
 	}
@@ -7623,8 +7610,7 @@  vectorizable_induction (gimple *phi,
 	  new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop),
 						 new_stmt);
 	  gcc_assert (!new_bb);
-	  set_vinfo_for_stmt (new_stmt,
-			      new_stmt_vec_info (new_stmt, loop_vinfo));
+	  loop_vinfo->add_stmt (new_stmt);
 	}
     }
   else
@@ -7728,15 +7714,14 @@  vectorizable_induction (gimple *phi,
   /* Create the induction-phi that defines the induction-operand.  */
   vec_dest = vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_");
   induction_phi = create_phi_node (vec_dest, iv_loop->header);
-  set_vinfo_for_stmt (induction_phi,
-		      new_stmt_vec_info (induction_phi, loop_vinfo));
+  stmt_vec_info induction_phi_info = loop_vinfo->add_stmt (induction_phi);
   induc_def = PHI_RESULT (induction_phi);
 
   /* Create the iv update inside the loop  */
   vec_def = make_ssa_name (vec_dest);
   new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step);
   gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
-  set_vinfo_for_stmt (new_stmt, new_stmt_vec_info (new_stmt, loop_vinfo));
+  stmt_vec_info new_stmt_info = loop_vinfo->add_stmt (new_stmt);
 
   /* Set the arguments of the phi node:  */
   add_phi_arg (induction_phi, vec_init, pe, UNKNOWN_LOCATION);
@@ -7781,7 +7766,7 @@  vectorizable_induction (gimple *phi,
       vec_step = vect_init_vector (phi, new_vec, vectype, NULL);
 
       vec_def = induc_def;
-      prev_stmt_vinfo = vinfo_for_stmt (induction_phi);
+      prev_stmt_vinfo = induction_phi_info;
       for (i = 1; i < ncopies; i++)
 	{
 	  /* vec_i = vec_prev + vec_step  */
@@ -7791,10 +7776,9 @@  vectorizable_induction (gimple *phi,
 	  gimple_assign_set_lhs (new_stmt, vec_def);
  
 	  gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
-	  set_vinfo_for_stmt (new_stmt,
-			      new_stmt_vec_info (new_stmt, loop_vinfo));
+	  new_stmt_info = loop_vinfo->add_stmt (new_stmt);
 	  STMT_VINFO_RELATED_STMT (prev_stmt_vinfo) = new_stmt;
-	  prev_stmt_vinfo = vinfo_for_stmt (new_stmt);
+	  prev_stmt_vinfo = new_stmt_info;
 	}
     }
 
Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	2018-07-24 10:22:09.237496975 +0100
+++ gcc/tree-vect-slp.c	2018-07-24 10:22:19.805403136 +0100
@@ -2494,7 +2494,7 @@  _bb_vec_info::_bb_vec_info (gimple_stmt_
     {
       gimple *stmt = gsi_stmt (gsi);
       gimple_set_uid (stmt, 0);
-      set_vinfo_for_stmt (stmt, new_stmt_vec_info (stmt, this));
+      add_stmt (stmt);
     }
 
   bb->aux = this;
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	2018-07-13 10:11:14.533842692 +0100
+++ gcc/tree-vect-stmts.c	2018-07-24 10:22:19.809403100 +0100
@@ -1744,7 +1744,7 @@  vect_finish_stmt_generation_1 (gimple *s
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
   vec_info *vinfo = stmt_info->vinfo;
 
-  set_vinfo_for_stmt (vec_stmt, new_stmt_vec_info (vec_stmt, vinfo));
+  vinfo->add_stmt (vec_stmt);
 
   if (dump_enabled_p ())
     {
@@ -4183,8 +4183,7 @@  vectorizable_simd_clone_call (gimple *st
 		    }
 		  tree phi_res = copy_ssa_name (op);
 		  gphi *new_phi = create_phi_node (phi_res, loop->header);
-		  set_vinfo_for_stmt (new_phi,
-				      new_stmt_vec_info (new_phi, loop_vinfo));
+		  loop_vinfo->add_stmt (new_phi);
 		  add_phi_arg (new_phi, arginfo[i].op,
 			       loop_preheader_edge (loop), UNKNOWN_LOCATION);
 		  enum tree_code code
@@ -4201,8 +4200,7 @@  vectorizable_simd_clone_call (gimple *st
 		    = gimple_build_assign (phi_arg, code, phi_res, tcst);
 		  gimple_stmt_iterator si = gsi_after_labels (loop->header);
 		  gsi_insert_after (&si, new_stmt, GSI_NEW_STMT);
-		  set_vinfo_for_stmt (new_stmt,
-				      new_stmt_vec_info (new_stmt, loop_vinfo));
+		  loop_vinfo->add_stmt (new_stmt);
 		  add_phi_arg (new_phi, phi_arg, loop_latch_edge (loop),
 			       UNKNOWN_LOCATION);
 		  arginfo[i].op = phi_res;
@@ -6731,7 +6729,7 @@  vectorizable_store (gimple *stmt, gimple
 		 loop, &incr_gsi, insert_after,
 		 &offvar, NULL);
       incr = gsi_stmt (incr_gsi);
-      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));
+      loop_vinfo->add_stmt (incr);
 
       stride_step = cse_and_gimplify_to_preheader (loop_vinfo, stride_step);
 
@@ -7729,7 +7727,7 @@  vectorizable_load (gimple *stmt, gimple_
 		 loop, &incr_gsi, insert_after,
 		 &offvar, NULL);
       incr = gsi_stmt (incr_gsi);
-      set_vinfo_for_stmt (incr, new_stmt_vec_info (incr, loop_vinfo));
+      loop_vinfo->add_stmt (incr);
 
       stride_step = cse_and_gimplify_to_preheader (loop_vinfo, stride_step);
 
@@ -8488,8 +8486,7 @@  vectorizable_load (gimple *stmt, gimple_
 					        (gimple_assign_rhs1 (stmt))));
 		      new_temp = vect_init_vector (stmt, tem, vectype, NULL);
 		      new_stmt = SSA_NAME_DEF_STMT (new_temp);
-		      set_vinfo_for_stmt (new_stmt,
-					  new_stmt_vec_info (new_stmt, vinfo));
+		      vinfo->add_stmt (new_stmt);
 		    }
 		  else
 		    {
Index: gcc/tree-vect-patterns.c
===================================================================
--- gcc/tree-vect-patterns.c	2018-07-18 18:44:23.517905682 +0100
+++ gcc/tree-vect-patterns.c	2018-07-24 10:22:19.805403136 +0100
@@ -103,11 +103,7 @@  vect_init_pattern_stmt (gimple *pattern_
 {
   stmt_vec_info pattern_stmt_info = vinfo_for_stmt (pattern_stmt);
   if (pattern_stmt_info == NULL)
-    {
-      pattern_stmt_info = new_stmt_vec_info (pattern_stmt,
-					     orig_stmt_info->vinfo);
-      set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);
-    }
+    pattern_stmt_info = orig_stmt_info->vinfo->add_stmt (pattern_stmt);
   gimple_set_bb (pattern_stmt, gimple_bb (orig_stmt_info->stmt));
 
   STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info->stmt;
@@ -141,9 +137,7 @@  append_pattern_def_seq (stmt_vec_info st
   vec_info *vinfo = stmt_info->vinfo;
   if (vectype)
     {
-      gcc_assert (!vinfo_for_stmt (new_stmt));
-      stmt_vec_info new_stmt_info = new_stmt_vec_info (new_stmt, vinfo);
-      set_vinfo_for_stmt (new_stmt, new_stmt_info);
+      stmt_vec_info new_stmt_info = vinfo->add_stmt (new_stmt);
       STMT_VINFO_VECTYPE (new_stmt_info) = vectype;
     }
   gimple_seq_add_stmt_without_update (&STMT_VINFO_PATTERN_DEF_SEQ (stmt_info),
@@ -3832,8 +3826,7 @@  vect_recog_bool_pattern (stmt_vec_info s
 	  rhs = rhs2;
 	}
       pattern_stmt = gimple_build_assign (lhs, SSA_NAME, rhs);
-      pattern_stmt_info = new_stmt_vec_info (pattern_stmt, vinfo);
-      set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);
+      pattern_stmt_info = vinfo->add_stmt (pattern_stmt);
       STMT_VINFO_DATA_REF (pattern_stmt_info)
 	= STMT_VINFO_DATA_REF (stmt_vinfo);
       STMT_VINFO_DR_WRT_VEC_LOOP (pattern_stmt_info)
@@ -3958,8 +3951,7 @@  vect_recog_mask_conversion_pattern (stmt
 	}
       gimple_call_set_nothrow (pattern_stmt, true);
 
-      pattern_stmt_info = new_stmt_vec_info (pattern_stmt, vinfo);
-      set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);
+      pattern_stmt_info = vinfo->add_stmt (pattern_stmt);
       if (STMT_VINFO_DATA_REF (stmt_vinfo))
 	{
 	  STMT_VINFO_DATA_REF (pattern_stmt_info)
@@ -4290,9 +4282,7 @@  vect_recog_gather_scatter_pattern (stmt_
 
   /* Copy across relevant vectorization info and associate DR with the
      new pattern statement instead of the original statement.  */
-  stmt_vec_info pattern_stmt_info = new_stmt_vec_info (pattern_stmt,
-						       loop_vinfo);
-  set_vinfo_for_stmt (pattern_stmt, pattern_stmt_info);
+  stmt_vec_info pattern_stmt_info = loop_vinfo->add_stmt (pattern_stmt);
   STMT_VINFO_DATA_REF (pattern_stmt_info) = dr;
   STMT_VINFO_DR_WRT_VEC_LOOP (pattern_stmt_info)
     = STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info);