On Mon, 2 Aug 2021, Richard Sandiford wrote:

> Richard Biener <rguent...@suse.de> writes:
> > On Fri, 30 Jul 2021, Richard Sandiford wrote:
> >> > @@ -9456,6 +9499,51 @@ vectorizable_load (vec_info *vinfo,
> >> >                          data_ref = NULL_TREE;
> >> >                          break;
> >> >                        }
> >> > +                    else if (memory_access_type == VMAT_GATHER_SCATTER)
> >> > +                      {
> >> > +                        /* Emulated gather-scatter.  */
> >> > +                        gcc_assert (!final_mask);
> >> 
> >> For this to be safe, we need to make sure that
> >> check_load_store_for_partial_vectors clears
> >> LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P.  Is that already guaranteed?
> >> (Maybe yes, I didn't look closely. :-))
> >
> > I've made sure to fail earlier:
> >
> > @@ -8692,6 +8725,15 @@ vectorizable_load (vec_info *vinfo,
> >                              "unsupported access type for masked 
> > load.\n");
> >           return false;
> >         }
> > +      else if (memory_access_type == VMAT_GATHER_SCATTER
> > +              && gs_info.ifn == IFN_LAST
> > +              && !gs_info.decl)
> > +       {
> > +         if (dump_enabled_p ())
> > +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> > +                            "unsupported masked emulated gather.\n");
> > +         return false;
> > +       }
> >      }
> >
> > at least I don't see a way to emulate masked gathers ;)
> 
> Yeah, that handles masked loads created by ifcvt.  But we also need to
> protect against an unconditional load being converted into a predicated
> load for partial loop vectorisation.  I think we still need a check in
> check_load_store_for_partial_vectors to handle that.  The check wouldn't
> prevent vectorisation, it would just prevent using fully-predicated loops.

But that seems to check for availability of the masked gather IFN which
of course isn't available and then sets 
LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P to false:

  if (memory_access_type == VMAT_LOAD_STORE_LANES)
    {
      if (is_load
          ? !vect_load_lanes_supported (vectype, group_size, true)
          : !vect_store_lanes_supported (vectype, group_size, true))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                             "can't operate on partial vectors because"
                             " the target doesn't have an appropriate"
                             " load/store-lanes instruction.\n");
          LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false;
          return;

Richard.

> Thanks,
> Richard
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

Reply via email to