On Wed, 14 May 2025, Richard Sandiford wrote:

> Richard Biener <rguent...@suse.de> writes:
> > The following includes whether we vectorize an epilogue, whether
> > we use loop masking and what vectorization factor (unroll factor)
> > we use.  So it's now
> >
> > t.c:4:21: optimized: loop vectorized using 64 byte vectors and unroll 
> > factor 32
> > t.c:4:21: optimized: epilogue loop vectorized using masked 64 byte vectors 
> > and unroll factor 32
> >
> > for a masked epilogue with AVX512 and HImode data for example.  Rather
> > than
> >
> > t.c:4:21: optimized: loop vectorized using 64 byte vectors
> > t.c:4:21: optimized: loop vectorized using 64 byte vectors
> >
> > I verified we don't translate opt-info messages and thus excessive
> > use of %s to compose the strings should be OK.
> >
> > Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu
> > (merely to look for testcases scanning for the old message too
> > closely).
> >
> > Any comments or suggestions for improvements?
> 
> It might be worth adding the vector-level unroll factor for the
> variable-length case (suggested_unroll_factor), but that could be
> a future change.

Yes.  I wonder if

optimized: loop vectorized using variable length vectors and unroll factor 
2

makes "sense"?  The '2' doesn't cover the variable unroll part.
Maybe instead "loop vectorized using variable length vectors and
unrolled 2 times"?

For the fixed-length vector case the reported unroll factor includes
both the vector-level and "regular" unrolling (in fact the vector-level
"unrolling" part depends on the element size for mixed element size
loops).

> So LGTM FWIW.  Thanks for doing this.

Pushed with required adjustment of gcc.target/i386/pr110310.c

Richard.

> Richard
> 
> >
> >     * tree-vectorizer.cc (vect_transform_loops): When diagnosing
> >     a vectorized loop indicate whether we vectorized an epilogue,
> >     whether we used masked vectors and what unroll factor was
> >     used.
> > ---
> >  gcc/tree-vectorizer.cc | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc
> > index 447f882c518..2f77e46ba99 100644
> > --- a/gcc/tree-vectorizer.cc
> > +++ b/gcc/tree-vectorizer.cc
> > @@ -1026,10 +1026,19 @@ vect_transform_loops (hash_table<simduid_to_vf> 
> > *&simduid_to_vf_htab,
> >      {
> >        if (GET_MODE_SIZE (loop_vinfo->vector_mode).is_constant (&bytes))
> >     dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
> > -                    "loop vectorized using %wu byte vectors\n", bytes);
> > +                    "%sloop vectorized using %s%wu byte vectors and"
> > +                    " unroll factor %u\n",
> > +                    LOOP_VINFO_EPILOGUE_P (loop_vinfo)
> > +                    ? "epilogue " : "",
> > +                    LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)
> > +                    ? "masked " : "", bytes,
> > +                    (unsigned int) LOOP_VINFO_VECT_FACTOR
> > +                                            (loop_vinfo).to_constant ());
> >        else
> >     dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
> > -                    "loop vectorized using variable length vectors\n");
> > +                    "%sloop vectorized using variable length vectors\n",
> > +                    LOOP_VINFO_EPILOGUE_P (loop_vinfo)
> > +                    ? "epilogue " : "");
> >      }
> >  
> >    loop_p new_loop = vect_transform_loop (loop_vinfo,
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to