From 06c81a5293af83b78cd9b6db22e2efa98a207748 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 11 Aug 2019 21:40:49 -0400 Subject: [PATCH] Change _mm_cvtps_epi32 (rounding conversion) to _mm_cvttps_epi32 (truncating conversion) in float_4 -> int32_4 cast. Add << and >> operators for int32_4. --- include/simd/vector.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/simd/vector.hpp b/include/simd/vector.hpp index 8508e7dc..566b26a2 100644 --- a/include/simd/vector.hpp +++ b/include/simd/vector.hpp @@ -152,7 +152,7 @@ inline Vector::Vector(Vector a) { } inline Vector::Vector(Vector a) { - v = _mm_cvtps_epi32(a.v); + v = _mm_cvttps_epi32(a.v); } inline Vector Vector::cast(Vector a) { @@ -346,6 +346,16 @@ inline Vector operator~(const Vector& a) { return a ^ Vector::mask(); } +/** `a << b` */ +inline Vector operator<<(const Vector& a, const int& b) { + return Vector(_mm_slli_epi32(a.v, b)); +} + +/** `a >> b` */ +inline Vector operator>>(const Vector& a, const int& b) { + return Vector(_mm_srli_epi32(a.v, b)); +} + // Typedefs