[cfe-dev] [PATCH] [OpenCL] Conversions for ternary operations between scalar and vector
Sahasrabuddhe, Sameer
sameer.sahasrabuddhe at amd.com
Wed Dec 17 10:26:18 PST 2014
On 12/17/2014 6:33 PM, Colin Riddell wrote:
>
> I have went through the examples you provided and marked which rules I
> disagree/am unsure about
>> Some notable examples:
>>
>> exp1 exp2 exp3 result eval reason
>> --------+-------+--------+--------+--------+--------
>> char2 int int error - 7.1
> Can you remind me where the wording about number of bits matching
> is.... I am not sure about this one because 220 also states that "
> The second and third expressions can be any type, as long their types
> match". Which to me, suggests that the char2 ? int : int example is
> allowed. Also in table 6.14, for select() in c ? b : a a and b
> need to have matching types, but c can be different as long as its
> integer
Page 220 also states that if the condition is a vector, then the
operator is equivalent to calling the select builtin. The select builtin
in table 6.14 says that c must have the same number of elements and
*bits* as the other two.
>> char2 int2 int2 error - 4.1
> Same logic applies for this.
>> int2 char char error - 7.1
> And this.
>> int2 int2 float2 error - 5
> Agree it should error, but because no implicit conversion is allowed
> between int2 and float2
Yup. The "5" here refers to point 5, which in turn specifies that "usual
arithmetic conversions" (Section 6.2.6) are used. The same section says
that no implicit conversion is allowed. So we are both saying the same
thing.
>> int2 int2 float error - 5
> Not sure about this one, my understanding here is that an attempt will
> be made at converting the float to a vec2. Maybe I misunderstand this
> rule?
Section 6.2.6 states that the scalar cannot be of higher rank than the
vector when converting. Looking at it another way, if we managed to
convert the float to a float2, it cannot be implicitly converted to int2
or vice versa.
>> int2 char2 char2 error - 4.1
> Same as my first point
And same explanation applies. The difference between 4.1 and 7.1 is that
in 4.1, the result type is already a vector type and the rules of the
select builtin apply right away. But in 7.1, the result type is a scalar
type, and this is probably undefined behaviour. We are choosing to
define it as if the scalar was turned into a vector without changing its
element type, which is not covered by any conversion rule.
Sameer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141217/0d607d8f/attachment.html>
More information about the cfe-dev
mailing list