https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121536

--- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 14 Aug 2025, tnfchris at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121536
> 
> --- Comment #3 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
> Richi: g:fb59c5719c17a04ecfd58b5e566eccd6d2ac583a is problematic for us 
> because
> without the type we can't tell which one of our scalar register file the
> operation is working on.
> 
> e.g. a + b has different costing between int and float.
> 
> So we need either the GIMPLE statement of the type of the statement being
> costed otherwise we can't distinguish between them. e.g. just `scalar_stmt`
> does not give us enough information.

See how x86 solves this issue:

unsigned
ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
                                  stmt_vec_info stmt_info, slp_tree node,
                                  tree vectype, int,
                                  vect_cost_model_location where)
{
  unsigned retval = 0;
  bool scalar_p
    = (kind == scalar_stmt || kind == scalar_load || kind == 
scalar_store);
  int stmt_cost = - 1;

  bool fp = false;
  machine_mode mode = scalar_p ? SImode : TImode;

  if (vectype != NULL)
    {
      fp = FLOAT_TYPE_P (vectype);
      mode = TYPE_MODE (vectype);
      if (scalar_p)
        mode = TYPE_MODE (TREE_TYPE (vectype));
    }
  /* When we are costing a scalar stmt use the scalar stmt to get at the
     type of the operation.  */
  else if (scalar_p && stmt_info)
    if (tree lhs = gimple_get_lhs (stmt_info->stmt))
      {
        fp = FLOAT_TYPE_P (TREE_TYPE (lhs));
        mode = TYPE_MODE (TREE_TYPE (lhs));

Reply via email to