SIMD types and aliasing rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a question about SIMD vector types and the gcc aliasing rules.

For simplicity, suppose sizeof(int)==4, and consider the following code:

#include <stdio.h>

typedef int v4si __attribute__ ((vector_size(16)));

int main(void)
{
        v4si y = { 1, 1, 1, 1 };
        v4si x = { 0, 2, 0, 4 };

        ((int *)&x)[0] = 1;
        ((int *)&x)[2] = 3;

        x += y;

        printf("%d %d %d %d\n", ((int *)&x)[0],
          ((int *)&x)[1], ((int *)&x)[2], ((int *)&x)[3]);

        return 0;
}

Is this code correct? If not, what is the correct portable (within gcc) way to read or write a member of a vector?

Best,
--Lorenz


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux