[PATCH] Add emulated gather capability to the vectorizer

Richard Sandiford richard.sandiford@arm.com
Mon Aug 2 08:05:20 GMT 2021


Richard Biener <rguenther@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.

Thanks,
Richard


More information about the Gcc-patches mailing list