I would like to know if I'm breaking strict aliasing rules with this snippet. (I think so since it's dereferencing a punned-pointer, however it's done in a single expression and /Wall doesn't cry.)
inline double plop() const // member function
{
__m128d x = _mm_load_pd(v);
... // some stuff
return *(reinterpret_cast<double*>(&x)); // return the lower double in xmm reg referred to by x.
}
If yes, what's the workaround? Using different representations simultaneously is becoming hardcore once you want to respect the spec.
Thanks for your answers, I'm losing my good mood trying to find a solution.
Answers that won't be accepted and why:
"use mm_store" -> The optimizer fails to remove it if the following instructions require an xmm register so it generates a load just after it. Store + load for nothing.
"use a union" -> Aliasing rule violation if using the two types for the same object. If I understood well the article written by Thiago Macieira.