From 0cce94983701544bd8d9e3b2c2c4d9952e28e6c5 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Mon, 30 Jan 2017 12:25:51 +0100 Subject: [PATCH] Fix the last bug that prevented AVX from working properly. Hopefully this fixes all other SIMD related problems too --- simgear/math/simd.hxx | 53 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/simgear/math/simd.hxx b/simgear/math/simd.hxx index a0f82800..4ea04a4b 100644 --- a/simgear/math/simd.hxx +++ b/simgear/math/simd.hxx @@ -99,7 +99,6 @@ inline simd4_t cross(const simd4_t& v1, const simd4_t& v2) d[0] = v1[1]*v2[2] - v1[2]*v2[1]; d[1] = v1[2]*v2[0] - v1[0]*v2[2]; d[2] = v1[0]*v2[1] - v1[1]*v2[0]; - d[3] = T(0); return d; } @@ -163,6 +162,14 @@ public: return vec[n]; } + template + inline simd4_t& operator=(simd4_t v) { + for (int i=0; i& operator+=(T s) { for (int i=0; i + inline simd4_t& operator=(const simd4_t v) { + simd4 = v.v4(); + return *this; + } + inline simd4_t& operator=(const __m128& v) { + simd4 = v; + return *this; + } + inline simd4_t& operator+=(float f) { simd4 = _mm_add_ps(simd4, _mm_set1_ps(f)); return *this; @@ -554,7 +571,7 @@ inline simd4_tabs(simd4_t v) { # endif -# ifdef __AVX_unsupported__ +# ifdef __AVX__ # include ALIGN32 @@ -625,6 +642,16 @@ public: return vec[n]; } + template + inline simd4_t& operator=(const simd4_t v) { + simd4 = v.v4(); + return *this; + } + inline simd4_t& operator=(const __m256d& v) { + simd4 = v; + return *this; + } + inline simd4_t& operator+=(double d) { simd4 = _mm256_add_pd(simd4, _mm256_set1_pd(d)); return *this; @@ -843,6 +870,18 @@ public: return vec[n]; } + template + inline simd4_t& operator=(const simd4_t v) { + simd4[0] = v.v4()[0]; + simd4[1] = v.v4()[1]; + return *this; + } + inline simd4_t& operator=(const __m128d v[2]) { + simd4[0] = v[0]; + simd4[1] = v[1]; + return *this; + } + inline simd4_t& operator+=(double d) { __m128d d4 = _mm_set1_pd(d); simd4[0] = _mm_add_pd(simd4[0], d4); @@ -1102,6 +1141,16 @@ public: return vec[n]; } + template + inline simd4_t& operator=(const simd4_t v) { + simd4 = v.v4(); + return *this; + } + inline simd4_t& operator=(const __m128& v) { + simd4 = v; + return *this; + } + inline simd4_t& operator+=(int i) { simd4 = _mm_add_epi32(simd4, _mm_set1_epi32(i)); return *this;