This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Teach the vectorizer about multiple sizes


On 10/06/2010 05:45 AM, Richard Guenther wrote:
> +   /* Query the preferred simd mode and if that does not match the
> +      requested size get a supported mode based on its mode class.  */
>     simd_mode = targetm.vectorize.preferred_simd_mode (inner_mode);
> +   if (size != 0
> +       && size != GET_MODE_SIZE (simd_mode))
> +     {
> +       simd_mode = mode_for_size (size *  BITS_PER_UNIT,
> + 				 GET_MODE_CLASS (simd_mode), 0);
> +       if (simd_mode == BLKmode
> + 	  || !targetm.vector_mode_supported_p (simd_mode))
> + 	return NULL_TREE;
> +     }

I have trouble believing that this is either sufficient or 
correct.  First, mode_for_size isn't being given anything
but the total vector size; it's not being given the inner mode.
So you'd need to iterate over the set of modes to find one
that matches the inner mode you're looking for.  E.g. split
out the loop from layout_type, case vector_type.

Second, when an explicit size is requested I don't see why
you should bother with preferred_simd_mode at all.

> !   /* Autodetect first vector size we try.  */
> !   current_vector_size = 0;
> !   vector_sizes = targetm.vectorize.autovectorize_vector_sizes ();
...
> !       vector_sizes &= ~current_vector_size;
> !       if (vector_sizes == 0)
> ! 	return NULL;
> ! 
> !       /* Try the next biggest vector size.  */
> !       current_vector_size = 1 << floor_log2 (vector_sizes);

This seems slightly odd.  Consider

  c_v_s = 0;
  v_s = 32 | 16;

  // first loop
  c_v_s = 16; // via autodetection

  v_s &= ~c_v_s; -> 32;

  c_v_s = 1 << floor_log2(32) -> 32

  // second loop
  did we really want to get here?

A reasonable assumption for this is that c_v_s should be 
decreasing only.  Perhaps better to do

  v_s &= c_v_s - 1;

i.e. remove c_v_s and all larger sizes.

Nit: I prefer while (1) { } over do { } while (1).



r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]