Usually I work with 3D vectors using following types:
typedef vec3_t float[3];
initializing vectors using smth. like:
vec3_
You are forgetting that you need to reinterpret a as array of floats. Following code works properly:
int main(){
v4sf a,b,c;
a = (v4sf){0.1f,0.2f,0.3f,0.4f};
b = (v4sf){0.1f,0.2f,0.3f,0.4f};
c = (v4sf){0.1f,0.2f,0.3f,0.4f};
a = b + c;
float* pA = (float*) &a;
printf("a=[%f %f %f %f]\n",pA[0], pA[1], pA[2], pA[3]);
return 0;
}
P.S.: thanks for this question, I didn't know that gcc has such SSE support.
UPDATE: This solution fails once arrays got unaligned. Solution provided by @drhirsh is free from this problem.