From f163fcd043d3cf99fd44724c53df5966a88634f1 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Wed, 18 Apr 2018 00:00:47 +0300 Subject: [PATCH] simd: load vec3 helpers for sse/sse2 --- include/cglm/simd/intrin.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/cglm/simd/intrin.h b/include/cglm/simd/intrin.h index c396686..7fdfc2a 100644 --- a/include/cglm/simd/intrin.h +++ b/include/cglm/simd/intrin.h @@ -46,6 +46,25 @@ glm_simd_norm(__m128 a) { return _mm_sqrt_ps(glm_simd_dot(a, a)); } +static inline +__m128 +glm_simd_load_v3(vec3 v) { + __m128i xy; + __m128 z; + + xy = _mm_loadl_epi64((const __m128i *)v); + z = _mm_load_ss(&v[2]); + + return _mm_movelh_ps(_mm_castsi128_ps(xy), z); +} + +static inline +void +glm_simd_store_v3(__m128 vx, vec3 v) { + _mm_storel_pi((__m64 *)&v[0], vx); + _mm_store_ss(&v[2], _mm_shuffle1_ps(vx, 2, 2, 2, 2)); +} + #endif /* x86, x64 */