Original Post
Hello, Just for fun, I'm trying to write a 4-floats vector that uses SSE instructions. I've seen that sort of code in many places:
struct Vec4
{
union {
__m128 v;
struct { float x, y, z, w; };
};
}; This code compiles just fine but one comment in Microsoft's doc raises some questions: Quote:To me it looks like using this construct is equivalent to accessing each field directly. What do I risk if I still keep that ? Illegal/faulty code ? Less performance (if that lib were used in a real project) ? What I believe in fact is that every time I will access fields directly, some extra load/store operations will occur which will harm performance a bit. On the other hand, if I *do* need to read/write a field between two calculations without accessing it directly, I will have to do the store/load myself. What do you think/know about that ? Thank you for reading this. JA
You should not access the __m128 fields directly. You can, however, see these types in the debugger. A variable of type __m128 maps to the XMM[0-7] registers.