> Am 18.07.2024 um 17:37 schrieb Alexander Monakov <amona...@ispras.ru>:
>
>
> On Thu, 18 Jul 2024, Richard Biener wrote:
>
>>> If both b and c are scalars and the type of true?b:c has the same size
>>> as the element type of a, then b and c are converted to a vector type
>>> whose elements have this type and with the same number of elements as a.
>>>
>>> (in https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html )
>>
>> But sizeof(typeof(true?‘a‘:‘b‘)) is four nevertheless the C++ frontend
>> produces vectors of char.
>
> It is 1 in C++; in C it is four because 'a' has type int, not char.
Ah, of course…
> (also, in C op2 and op3 of a ternary operator always have integer promotions
> applied, but for vector selection we should use unpromoted types)
Yes. So a good testcase would use char typed variable then. It’s unfortunate
C and C++ do not behave the same here.
Do you read the OpenCL standard the same in not supporting two scalar types
here?
>>> I think we require that sizes match because that's natural considering
>>> how it is lowered (bitwise blending of comparison mask with op2/op3).
>>
>> It works naturally for mixed sizes with for example AVX512 and better
>> lowering
>> could be implemented for SSE.
>
> Yeah, I'm just saying it makes sense to me from a historical perspective.
> I won't object if in C vector c?a:b is more useful than in C++.
>
> Alexander