This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SIMD types and aliasing rules


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]