I have the two following situations, which to me should be similar, but apparently are not.
This one does not work, while this would be more ideal:
static union { __m256 trueMask8; float trueMask[8]; };
void Init()
{
trueMask8 = _mm256_cmp_ps(_mm256_setzero_ps(), _mm256_setzero_ps(), _CMP_EQ_OS);
}
class Ray8
{
union { __m256 activeMask8; float deadMask[8]; };
Ray8()
{
activeMask8 = trueMask8;
int w = 0; //breakpoint
}
}
The problem with the one above is that activeMask8 shows all 0 on the breakpoint, while trueMask8 shows all -nan, so I'm sure the Init has been called.
The one below works, but its less ideal since every time I need a true mask I need to call the compare:
class Ray8
{
union { __m256 activeMask8; float deadMask[8]; };
Ray8()
{
activeMask8 = _mm256_cmp_ps(_mm256_setzero_ps(), _mm256_setzero_ps(), _CMP_EQ_OS);
int w = 0; //breakpoint
}
}
Here everything in activeMask8 is -1 at the breakpoint.
The same goes for:
activeMask[0] = trueMask[0];
Which are two floats. trueMask[0] shows -nan, while activeMask[0] shows 0 afterwards.
Why does this occur? I would normally try to make a copy constructor, but _m256 is a library type. Is there a solution to this?