fix ASAN error in Vec2<float>::Length()

This commit is contained in:
oltolm 2023-11-27 19:23:50 +01:00
parent c9d5b72683
commit 6e609342d6

View File

@ -26,7 +26,8 @@ float Vec2<float>::Length() const
// Doubt this is worth it for a vec2 :/ // Doubt this is worth it for a vec2 :/
#if defined(_M_SSE) #if defined(_M_SSE)
float ret; float ret;
__m128 xy = _mm_loadu_ps(&x); __m128d tmp = _mm_load_sd((const double*)&x);
__m128 xy = _mm_castpd_ps(tmp);
__m128 sq = _mm_mul_ps(xy, xy); __m128 sq = _mm_mul_ps(xy, xy);
const __m128 r2 = _mm_shuffle_ps(sq, sq, _MM_SHUFFLE(0, 0, 0, 1)); const __m128 r2 = _mm_shuffle_ps(sq, sq, _MM_SHUFFLE(0, 0, 0, 1));
const __m128 res = _mm_add_ss(sq, r2); const __m128 res = _mm_add_ss(sq, r2);