[cfe-dev] On which option should vector operator ? : depend?

Daniel Dunbar daniel at zuster.org
Wed Sep 29 10:06:21 PDT 2010


On Mon, Sep 27, 2010 at 11:03 AM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Sep 22, 2010, at 1:09 AM, Jochen Wilhelmy wrote:
>
>> Hi!
>>
>> I have a new idea: the vector operator ? : should depend on no option at
>> all,
>> because options like Altivec or OpenCL enable language extensions.
>> But vectors are created using e.g.
>> typedef float __attribute__((ext_vector_type(4))) float4;
>> Therefore if you have some vectors the operators +, -, *, / work and also
>> the operator ? : should work.
>
> I think it's perfectly reasonable for ? : to work on vectors, even if neither Altivec nor OpenCL are enabled.

I'm not sure I agree. What are the semantics?

In my opinion, the right semantics for ?: for vectors, relative to the
C language, is that (cond ? LHS : RHS <=> (cond == 0) ? LHS : RHS. But
that isn't a very useful operation on vectors, and may be surprising
to some users. I can see an argument for implementing it just for
orthogonality.

Having ?: mean a vector select seems wrong to me.

 - Daniel

>        - Doug
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list