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

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Hongtao.liu from comment #9)
> > But we end up here with niters_skip being INTEGER_CST and ..
> > 
> > > 1421      || (!vect_use_loop_mask_for_alignment_p (loop_vinfo)
> > 
> > possibly vect_use_loop_mask_for_alignment_p.  Note
> > LOOP_VINFO_PEELING_FOR_ALIGNMENT < 0 simply means the amount of
> > peeling is unknown.
> > 
> > But I wonder how we run into this on x86 without enabling
> > loop masking ...
> > 
> > > 1422          && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0))
> > > 1423    {
> > > 1424      if (dump_enabled_p ())
> > > 1425        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> > > 1426                         "Peeling for alignement is not supported"
> > > 1427                         " for nonlinear induction when niters_skip"
> > > 1428                         " is not constant.\n");
> > > 1429      return false;
> > > 1430    }
> 
> Can you point out where it's assigned as nagative?
> I saw LOOP_VINFO_MASK_SKIP_NITERS is only assigned in
> vect_prepare_for_masked_peels.

Yes.

> when LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) > 0
> it's assigned as vf-npeel(will npeel > vf?)

npeel should be < vf

OK, so it should be positive indeed.  But LOOP_VINFO_MASK_SKIP_NITERS
(when vect_use_loop_mask_for_alignment_p ()) means that the
first vector iteration only processes the first
vf - LOOP_VINFO_MASK_SKIP_NITERS scalar iterations, so a

 for (i = start; i < end; ++i)
   ..

loop is executed as

 for (i = start - LOOP_VINFO_MASK_SKIP_NITERS; i < end; ++i)
   if (i >= start)
     {
     }

that is, the loop mask is used to mask out the first
LOOP_VINFO_MASK_SKIP_NITERS elements.

It's a bit difficult to force peeling for alignment on x86, but
usually -fno-vect-cost-model will peel a store (it will peel the
most used ref for alignment).  With --param vect-partial-vector-usage=2
you should get AVX512 masked alignment peeling then I think.

Reply via email to