On Wed, Dec 03, 2025 at 01:29:39AM -0800, Andrew Pinski wrote:
> > -  stmt = gimple_build_assign (tidx, sub);
> > +  stmt = gimple_build_assign (uidx, sub);
> >
> >    gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
> > -  update_stmt (stmt);
> >    m_arr_ref_first = stmt;
> >
> > +  tidx = uidx;
> > +  if (tidxtype != utype)
> > +    {
> > +      tidx = make_ssa_name (tidxtype);
> > +      stmt = gimple_build_assign (tidx, NOP_EXPR, uidx);
> > +      gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
> > +    }
> Why not just simply:
> 
>   tidx = gimple_convert (&gsi, /* before =*/true, GSI_SAME_STMT,
> UNKNOWN_LOCATION, tidxtype, uidx);
> 
> This will insert a stmt as needed and if already
> useless_type_conversion_p is true, just return uidx.

That is definitely far more code than the above, and the above just
follows the style in the pass.  There is no point in trying to fold it
etc. because we know there is no point.
There are passes that do use gimple_convert/gimple_build etc., and passes
which don't.

        Jakub

Reply via email to