Richard Biener <richard.guent...@gmail.com> writes:
> On Tue, Nov 5, 2019 at 3:27 PM Richard Sandiford
> <richard.sandif...@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?

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.

Thanks,
Richard


>
>>
>> 2019-11-04  Richard Sandiford  <richard.sandif...@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;
>>      }
>>

Reply via email to