commit 31251decfe11bb78115f753835d27183f28cab2b
parent 4a0fe043bfabc12fb86c6464ba73b2dabc188d8d
Author: [email protected] <[email protected]>
Date: Wed, 10 Aug 2016 08:43:07 +0300
Use tovec to convert vec to mask
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/kfr/base/round.hpp b/include/kfr/base/round.hpp
@@ -92,25 +92,25 @@ template <size_t N>
KFR_SINTRIN vec<f32, N> floor(const vec<f32, N>& x)
{
vec<f32, N> t = cast<f32>(cast<i32>(x));
- return t - (bitcast<f32>(x < t) & 1.f);
+ return t - (tovec(x < t) & 1.f);
}
template <size_t N>
KFR_SINTRIN vec<f64, N> floor(const vec<f64, N>& x)
{
vec<f64, N> t = cast<f64>(cast<i64>(x));
- return t - (bitcast<f64>(x < t) & 1.0);
+ return t - (tovec(x < t) & 1.0);
}
template <size_t N>
KFR_SINTRIN vec<f32, N> ceil(const vec<f32, N>& x)
{
vec<f32, N> t = cast<f32>(cast<i32>(x));
- return t + (bitcast<f32>(x > t) & 1.f);
+ return t + (tovec(x > t) & 1.f);
}
template <size_t N>
KFR_SINTRIN vec<f64, N> ceil(const vec<f64, N>& x)
{
vec<f64, N> t = cast<f64>(cast<i64>(x));
- return t + (bitcast<f64>(x > t) & 1.0);
+ return t + (tovec(x > t) & 1.0);
}
template <size_t N>
KFR_SINTRIN vec<f32, N> round(const vec<f32, N>& x)
diff --git a/include/kfr/base/vec.hpp b/include/kfr/base/vec.hpp
@@ -1299,10 +1299,15 @@ constexpr CMT_INLINE vec<T, N> apply(Fn&& fn)
}
template <typename T, int N>
-CMT_INLINE vec<T, N> tovec(simd<T, N> x)
+CMT_INLINE vec<T, N> tovec(const simd<T, N>& x)
{
return x;
}
+template <typename T, int N>
+CMT_INLINE vec<T, N> tovec(const mask<T, N>& x)
+{
+ return *x;
+}
#ifdef CMT_ARCH_SSE2
CMT_INLINE f32x4 tovec(__m128 x) { return f32x4(x); }