>Something along these lines may be useful to do in the vectorizer when we
>get code like this:
>      > ((char)x) = ((char)( ((int)((char)x)) << ((int)c) ) )
>and don't feel like doing all the unpacking of chars to ints and then
>packing the ints to chars after the shift. An alternative could be to
>transform the above pattern to:
>      char_x1 = 0
>      char_x2 = char_x << c
>      char_x = ((int)c < size_of_char) ? char_x2 : char_x1
>and vectorize that (since we already know how to vectorize selects).

Alternatively, do
  char_c2 = (c < size_of_char ? c : 0)
  char_x2 = char_x << char_c2
which is like saturating the shift amount.

You could also try
  char_c2 = min(c, size_of_char)   /* And mask off a bit perhaps.  */
  char_x2 = char_x << char_c2
if you don't have general selects but do have min.

Ayal.

Reply via email to