Browse Source

Reverse order of float_4(float, float, float, float) and int32_4(int32_t, int32_t, int32_t, int32_t). Add simd::movemaskInverse().

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
f0c87ad969
2 changed files with 10 additions and 10 deletions
  1. +8
    -0
      include/simd/functions.hpp
  2. +2
    -10
      include/simd/vector.hpp

+ 8
- 0
include/simd/functions.hpp View File

@@ -186,6 +186,14 @@ inline float_4 sgn(float_4 x) {
return signbit | (nonzero & 1.f);
}

/** Given a mask `a`, returns a vector with each element either 0's or 1's depending on the mask bit. */
template <typename T>
inline T movemaskInverse(int a);

template <>
inline float_4 movemaskInverse<float_4>(int a) {
return float_4(a & (1 << 0), a & (1 << 1), a & (1 << 2), a & (1 << 3)) != float_4::zero();
}

} // namespace simd
} // namespace rack

+ 2
- 10
include/simd/vector.hpp View File

@@ -53,7 +53,7 @@ struct Vector<float, 4> {

/** Constructs a vector from four values. */
Vector(float x1, float x2, float x3, float x4) {
v = _mm_set_ps(x1, x2, x3, x4);
v = _mm_setr_ps(x1, x2, x3, x4);
}

/** Returns a vector initialized to zero. */
@@ -66,11 +66,6 @@ struct Vector<float, 4> {
return _mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
}

/** Constructs a vector from four values in reverse. */
static Vector setr(float x1, float x2, float x3, float x4) {
return Vector(_mm_setr_ps(x1, x2, x3, x4));
}

/** Reads an array of 4 values.
On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`.
*/
@@ -113,7 +108,7 @@ struct Vector<int32_t, 4> {
v = _mm_set1_epi32(x);
}
Vector(int32_t x1, int32_t x2, int32_t x3, int32_t x4) {
v = _mm_set_epi32(x1, x2, x3, x4);
v = _mm_setr_epi32(x1, x2, x3, x4);
}
static Vector zero() {
return Vector(_mm_setzero_si128());
@@ -121,9 +116,6 @@ struct Vector<int32_t, 4> {
static Vector mask() {
return Vector(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
}
static Vector setr(int32_t x1, int32_t x2, int32_t x3, int32_t x4) {
return Vector(_mm_setr_epi32(x1, x2, x3, x4));
}
static Vector load(const int32_t *x) {
// HACK
// Use _mm_loadu_si128() because GCC doesn't support _mm_loadu_si32()


Loading…
Cancel
Save