diff --git a/include/simd/vector.hpp b/include/simd/vector.hpp index 1d98ec5c..1eb4cbb0 100644 --- a/include/simd/vector.hpp +++ b/include/simd/vector.hpp @@ -77,6 +77,11 @@ struct Vector { void store(float *x) { _mm_storeu_ps(x, v); } + + // Conversions + Vector(Vector a); + // Casts + static Vector cast(Vector a); }; @@ -111,9 +116,31 @@ struct Vector { // Use _mm_storeu_si128() because GCC doesn't support _mm_storeu_si32() _mm_storeu_si128((__m128i*) x, v); } + Vector(Vector a); + static Vector cast(Vector a); }; +// Conversions and casts + + +inline Vector::Vector(Vector a) { + v = _mm_cvtepi32_ps(a.v); +} + +inline Vector::Vector(Vector a) { + v = _mm_cvtps_epi32(a.v); +} + +inline Vector Vector::cast(Vector a) { + return Vector(_mm_castsi128_ps(a.v)); +} + +inline Vector Vector::cast(Vector a) { + return Vector(_mm_castps_si128(a.v)); +} + + // Instructions not available as operators