On Mon, Mar 24, 2025 at 2:00 AM Richard Biener <richard.guent...@gmail.com> wrote: > > On Sun, Mar 23, 2025 at 9:46 PM Andrew Pinski <quic_apin...@quicinc.com> > wrote: > > > > In some cases (after inliing due to LTO and -O3), GCC cannot > > figure out that the length of the converts vect is not empty > > when supportable_indirect_convert_operation returns true. So > > we get an extra warning because we loop through all but the last > > entry and GCC decided that `converts.length () - 1` is -1. This > > adds an checking only assert to avoid the warning and maybe even > > produce slightly better code for this function. > > What about release checking then?
Thinking this over, I am going to replace gcc_checking_assert with gcc_assert. Since we are going to load the length of the vect anyways, checking if the vect is empty is almost free here and most likely produce better code in general. Since we currently don't change gcc_checking_assert into `if(!check) __builtin_unreachable()` ( I filed PR 119439 for that which also requires more work on the assume attribute usage too). Thanks, Andrew > > > Bootstrapped and tested on x86_64-linux-gnu. > > OK. > > > PR tree-optimization/118616 > > gcc/ChangeLog: > > > > * tree-vect-generic.cc (expand_vector_conversion): Add > > an assert that converts vect is non empty if > > supportable_indirect_convert_operation returns true. > > > > Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com> > > --- > > gcc/tree-vect-generic.cc | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc > > index 173ebd9a7ba..246297ec6a9 100644 > > --- a/gcc/tree-vect-generic.cc > > +++ b/gcc/tree-vect-generic.cc > > @@ -1759,6 +1759,7 @@ expand_vector_conversion (gimple_stmt_iterator *gsi) > > converts)) > > { > > new_rhs = arg; > > + gcc_checking_assert (!converts.is_empty ()); > > for (unsigned int i = 0; i < converts.length () - 1; i++) > > { > > new_lhs = make_ssa_name (converts[i].first); > > -- > > 2.43.0 > >