[2/6] Don't assign a cost to vectorizable_assignment

Richard Biener richard.guenther@gmail.com
Thu Nov 7 09:35:00 GMT 2019


On Wed, Nov 6, 2019 at 4:58 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Richard Biener <richard.guenther@gmail.com> writes:
> > On Tue, Nov 5, 2019 at 3:27 PM Richard Sandiford
> > <Richard.Sandiford@arm.com> wrote:
> >>
> >> vectorizable_assignment handles true SSA-to-SSA copies (which hopefully
> >> we don't see in practice) and no-op conversions that are required
> >> to maintain correct gimple, such as changes between signed and
> >> unsigned types.  These cases shouldn't generate any code and so
> >> shouldn't count against either the scalar or vector costs.
> >>
> >> Later patches test this, but it seemed worth splitting out.
> >
> > Hmm, but you have to adjust vect_compute_single_scalar_iteration_cost and
> > possibly the SLP cost walk as well, otherwise we're artificially making
> > those copies cheaper when vectorized.
>
> Ah, yeah.  It looks complicated to reproduce the conditions exactly
> there, so how about just costing 1 copy in vectorizable_assignment
> to counteract it, and ignore ncopies?

I guess costing a single scalar_stmt ought to make it exactly offset
the scalar cost?

> Seems like vectorizable_* ought to be costing the scalar code as
> well as the vector code, but that's too much for GCC 10 at this stage.

Yeah.

Richard.

> Thanks,
> Richard
>
>
> >
> >>
> >> 2019-11-04  Richard Sandiford  <richard.sandiford@arm.com>
> >>
> >> gcc/
> >>         * tree-vect-stmts.c (vectorizable_assignment): Don't add a cost.
> >>
> >> Index: gcc/tree-vect-stmts.c
> >> ===================================================================
> >> --- gcc/tree-vect-stmts.c       2019-11-05 14:17:43.330141911 +0000
> >> +++ gcc/tree-vect-stmts.c       2019-11-05 14:18:39.169752725 +0000
> >> @@ -5305,7 +5305,7 @@ vectorizable_conversion (stmt_vec_info s
> >>  static bool
> >>  vectorizable_assignment (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
> >>                          stmt_vec_info *vec_stmt, slp_tree slp_node,
> >> -                        stmt_vector_for_cost *cost_vec)
> >> +                        stmt_vector_for_cost *)
> >>  {
> >>    tree vec_dest;
> >>    tree scalar_dest;
> >> @@ -5313,7 +5313,6 @@ vectorizable_assignment (stmt_vec_info s
> >>    loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
> >>    tree new_temp;
> >>    enum vect_def_type dt[1] = {vect_unknown_def_type};
> >> -  int ndts = 1;
> >>    int ncopies;
> >>    int i, j;
> >>    vec<tree> vec_oprnds = vNULL;
> >> @@ -5409,7 +5408,8 @@ vectorizable_assignment (stmt_vec_info s
> >>      {
> >>        STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type;
> >>        DUMP_VECT_SCOPE ("vectorizable_assignment");
> >> -      vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, cost_vec);
> >> +      /* Don't add a cost here.  SSA copies and no-op conversions
> >> +        shouldn't generate any code in either scalar or vector form.  */
> >>        return true;
> >>      }
> >>



More information about the Gcc-patches mailing list