Browse Source

Change _mm_cvtps_epi32 (rounding conversion) to _mm_cvttps_epi32 (truncating conversion) in float_4 -> int32_4 cast. Add << and >> operators for int32_4.

tags/v1.1.4
Andrew Belt 5 years ago
parent
commit
06c81a5293
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      include/simd/vector.hpp

+ 11
- 1
include/simd/vector.hpp View File

@@ -152,7 +152,7 @@ inline Vector<float, 4>::Vector(Vector<int32_t, 4> a) {
}

inline Vector<int32_t, 4>::Vector(Vector<float, 4> a) {
v = _mm_cvtps_epi32(a.v);
v = _mm_cvttps_epi32(a.v);
}

inline Vector<float, 4> Vector<float, 4>::cast(Vector<int32_t, 4> a) {
@@ -346,6 +346,16 @@ inline Vector<int32_t, 4> operator~(const Vector<int32_t, 4>& a) {
return a ^ Vector<int32_t, 4>::mask();
}

/** `a << b` */
inline Vector<int32_t, 4> operator<<(const Vector<int32_t, 4>& a, const int& b) {
return Vector<int32_t, 4>(_mm_slli_epi32(a.v, b));
}

/** `a >> b` */
inline Vector<int32_t, 4> operator>>(const Vector<int32_t, 4>& a, const int& b) {
return Vector<int32_t, 4>(_mm_srli_epi32(a.v, b));
}


// Typedefs



Loading…
Cancel
Save