summaryrefslogtreecommitdiffstats
path: root/third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp')
-rw-r--r--third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp b/third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp
index a5b07ec9da..a4881778e0 100644
--- a/third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp
+++ b/third_party/xsimd/include/xsimd/arch/xsimd_avx2.hpp
@@ -76,6 +76,44 @@ namespace xsimd
}
}
+ // avgr
+ template <class A, class T, class = typename std::enable_if<std::is_unsigned<T>::value, void>::type>
+ inline batch<T, A> avgr(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx2>) noexcept
+ {
+ XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
+ {
+ return _mm256_avg_epu8(self, other);
+ }
+ else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
+ {
+ return _mm256_avg_epu16(self, other);
+ }
+ else
+ {
+ return avgr(self, other, generic {});
+ }
+ }
+
+ // avg
+ template <class A, class T, class = typename std::enable_if<std::is_unsigned<T>::value, void>::type>
+ inline batch<T, A> avg(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx2>) noexcept
+ {
+ XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
+ {
+ auto adj = ((self ^ other) << 7) >> 7;
+ return avgr(self, other, A {}) - adj;
+ }
+ else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
+ {
+ auto adj = ((self ^ other) << 15) >> 15;
+ return avgr(self, other, A {}) - adj;
+ }
+ else
+ {
+ return avg(self, other, generic {});
+ }
+ }
+
// bitwise_and
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
inline batch<T, A> bitwise_and(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx2>) noexcept