[PATCH][OPENCL] shift operator with vector operands

Pekka Jääskeläinen pekka.jaaskelainen at tut.fi
Thu Feb 5 07:09:51 PST 2015


LGTM!

On 02/05/2015 12:43 PM, Sameer Sahasrabuddhe wrote:
>
> This patch introduces a number of checks when the shift operator is used on
> OpenCL vectors:
>
>  1. If LHS is a scalar, then RHS cannot be a vector.
>  2. Operands must be of integer type.
>  3. If both are vectors, then the number of elements must match.
>
> Also, when LHS is a vector, a scalar RHS can simply be expanded into a vector;
> OpenCL does not require that its rank be lower than the LHS for "usual
> arithmetic conversions" defined in Section 6.2.6. This is because unlike other
> binary operators, the shift operators do not actually combine their operands.
> This is further supported by the fact that in OpenCL, the shift (RHS) is
> computed modulo the word-size of the LHS, and the effective shift value can
> always fit in a smaller type. For example, the following code is not an error
> even if the implicit type of the constant literal is "int":
>
>      char2 foo(char2 v) { return v << 1; }
>
> The patch additionally consolidates existing tests under CodeGenOpenCL, and
> creates more tests under SemaOpenCL.
>
> Sameer.


-- 
Pekka



More information about the cfe-commits mailing list