From 90707f8d4e48ba1e4271bd1874d514f04a64a981 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 27 Jul 2016 23:25:12 +0200 Subject: [PATCH] gsdx: avoid aliasing issue Extend GSVector to support float move Initial code likely used integer move for performance reason. However due to the nan correction, register is now in float domain. --- plugins/GSdx/GSState.cpp | 2 +- plugins/GSdx/GSVector.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index bdf79ed68b..d8dd1467cf 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -530,7 +530,7 @@ void GSState::GIFPackedRegHandlerSTQ(const GIFPackedReg* RESTRICT r) // Suikoden 4 creates some nan for Q. Let's avoid undefined behavior (See GIFRegHandlerRGBAQ) q = GSVector4i::cast(GSVector4::cast(q).replace_nan(GSVector4::m_max)); - *(int*)&m_q = GSVector4i::store(q); + GSVector4::store(&m_q, GSVector4::cast(q)); ASSERT(!std::isnan(m_v.ST.S)); // See GIFRegHandlerRGBAQ ASSERT(!std::isnan(m_v.ST.T)); // See GIFRegHandlerRGBAQ diff --git a/plugins/GSdx/GSVector.h b/plugins/GSdx/GSVector.h index 3dfd6ed70f..3da0ad1428 100644 --- a/plugins/GSdx/GSVector.h +++ b/plugins/GSdx/GSVector.h @@ -3100,6 +3100,11 @@ GSVector.h:2973:15: error: shadows template parm 'int i' else _mm_storeu_ps((float*)p, v.m); } + __forceinline static void store(float* p, const GSVector4& v) + { + _mm_store_ss(p, v.m); + } + __forceinline static void expand(const GSVector4i& v, GSVector4& a, GSVector4& b, GSVector4& c, GSVector4& d) { GSVector4i mask = GSVector4i::x000000ff();