[cfe-commits] [OpenCL patch] Clang fails on nested vector literals

John McCall rjmccall at apple.com
Wed Sep 28 10:38:03 PDT 2011


On Sep 28, 2011, at 6:32 AM, Anton Lokhmotov wrote:
>> Our code is more generic, as it allows nested vector initializers
>> (see OpenCL 6.1.6).  The added tests cover all possible uses.
>> 
>> Your patch breaks the following:
>> 
>> typedef int i4 __attribute((vector_size(16)));
>> i4 x = (i4){1,2};
>> 
>> It takes out the code that would otherwise pad the vector with zeros.
> 
> You are right.  But why was this behaviour used in the first place?
> 
> Both OpenCL 1.1 (http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf,
> p164) and AltiVec PIM
> (http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf, p26)
> say that the number of elements in the source must be equal to the number of
> elements in the result vector or one.  GCC vector extensions
> (http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html) are also silent
> on the issue.
> 
> Could you please point to a specification that says that missing vector
> elements must be filled with zeros?

Again, you seem to be treating (int4) { … } as an extension permitting
alternate syntax for OpenCL vector literals, which is not the case.  It is
the standard syntax for C99 compound literals.  The only extension
here is the ability to list-initialize the elements of a vector;  that extension
follows the usual rules for list initialization, which specify that members
not explicitly initialized are zero-initialized.

John.



More information about the cfe-commits mailing list