[Cbe-oss-dev] mars and fsf-gcc

Jonathan Adamczewski jadamcze at utas.edu.au
Sun Jun 7 23:21:38 EST 2009


Andrew Pinski wrote:
> On Sun, Jun 7, 2009 at 1:42 AM, Jonathan
> Adamczewski<jadamcze at utas.edu.au> wrote:
>> Attempting to compile mars-1.1.3 with spu-gcc-4.4.0 (as packaged for
>> debian sid), on the following code from base/src/mpu/kernel/kernel.c
>>
>> static int kernel_memcmp(const void *s1, const void *s2, int size)
>> {
>>        __vector const int *vptr_1 = (__vector const int *)s1;
>>        __vector const int *vptr_2 = (__vector const int *)s2;
>>        __vector const int *vptr_e = (__vector const int *)(s1 + size);
>>
>>        while (vptr_1 < vptr_e)
>>                if (!(*vptr_1++ == *vptr_2++))
>>                        return 1;
>>
>>        return 0;
>> }
>>
>>
>> I see this error :
>>
>> kernel.c: In function 'kernel_memcmp':
>> kernel.c:101: error: invalid operands to binary == (have 'const int
>> __vector__' and 'const int __vector__')
>>
>>
>> It appears that == is not supported for vectors in this version of
>> gcc, or I'm missing something obvious.
>>
> 
> well, I just submitted a patch to the FSF GCC to support this :).

Hah, thanks for the info.  I should try to keep up with my reading
of gcc-patches ;)


> 
> See http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01912.html .
> 
> Basically spu_equal followed by spu_collect (I think that is the
> intrinsics is called) will work.

Something like, (spu_extract(spu_gather(spu_cmpeq(a,b)))==0xf) I
suppose.


> But there are more issues with
> kernel_memcmp than just that, it looks like it does not handle the
> case where size is not a multiple of 16 and where s1 and s2 are not
> aligned to the 16 byte boundary either.

You're right.  That said, both calls to this function are with
suitably aligned/sized objects.

j.




More information about the cbe-oss-dev mailing list