Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/xsimd/arch/xsimd_avx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,12 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<float, A> max(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx>) noexcept
{
return _mm256_max_ps(self, other);
return _mm256_max_ps(other, self);
}
template <class A>
XSIMD_INLINE batch<double, A> max(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx>) noexcept
{
return _mm256_max_pd(self, other);
return _mm256_max_pd(other, self);
}
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
XSIMD_INLINE batch<T, A> max(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx>) noexcept
Expand All @@ -942,12 +942,12 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<float, A> min(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx>) noexcept
{
return _mm256_min_ps(self, other);
return _mm256_min_ps(other, self);
}
template <class A>
XSIMD_INLINE batch<double, A> min(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx>) noexcept
{
return _mm256_min_pd(self, other);
return _mm256_min_pd(other, self);
}
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
XSIMD_INLINE batch<T, A> min(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx>) noexcept
Expand Down
8 changes: 4 additions & 4 deletions include/xsimd/arch/xsimd_avx512f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,12 +1326,12 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<float, A> max(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx512f>) noexcept
{
return _mm512_max_ps(self, other);
return _mm512_max_ps(other, self);
}
template <class A>
XSIMD_INLINE batch<double, A> max(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx512f>) noexcept
{
return _mm512_max_pd(self, other);
return _mm512_max_pd(other, self);
}
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
XSIMD_INLINE batch<T, A> max(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx512f>) noexcept
Expand Down Expand Up @@ -1376,12 +1376,12 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<float, A> min(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx512f>) noexcept
{
return _mm512_min_ps(self, other);
return _mm512_min_ps(other, self);
}
template <class A>
XSIMD_INLINE batch<double, A> min(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx512f>) noexcept
{
return _mm512_min_pd(self, other);
return _mm512_min_pd(other, self);
}
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
XSIMD_INLINE batch<T, A> min(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx512f>) noexcept
Expand Down
8 changes: 4 additions & 4 deletions include/xsimd/arch/xsimd_sse2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<float, A> max(batch<float, A> const& self, batch<float, A> const& other, requires_arch<sse2>) noexcept
{
return _mm_max_ps(self, other);
return _mm_max_ps(other, self);
}
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
XSIMD_INLINE batch<T, A> max(batch<T, A> const& self, batch<T, A> const& other, requires_arch<sse2>) noexcept
Expand All @@ -1147,14 +1147,14 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<double, A> max(batch<double, A> const& self, batch<double, A> const& other, requires_arch<sse2>) noexcept
{
return _mm_max_pd(self, other);
return _mm_max_pd(other, self);
}

// min
template <class A>
XSIMD_INLINE batch<float, A> min(batch<float, A> const& self, batch<float, A> const& other, requires_arch<sse2>) noexcept
{
return _mm_min_ps(self, other);
return _mm_min_ps(other, self);
}
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
XSIMD_INLINE batch<T, A> min(batch<T, A> const& self, batch<T, A> const& other, requires_arch<sse2>) noexcept
Expand All @@ -1164,7 +1164,7 @@ namespace xsimd
template <class A>
XSIMD_INLINE batch<double, A> min(batch<double, A> const& self, batch<double, A> const& other, requires_arch<sse2>) noexcept
{
return _mm_min_pd(self, other);
return _mm_min_pd(other, self);
}

// mul
Expand Down
33 changes: 33 additions & 0 deletions test/test_xsimd_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,29 @@ struct xsimd_api_float_types_functions
value_type val(0);
CHECK_EQ(extract(xsimd::log1p(T(val))), std::log1p(val));
}

void test_max_nan()
{
value_type val0(2.7818);
value_type valN(NAN);
#if XSIMD_WITH_AVX || XSIMD_WITH_SSE2
using isnan = doctest::IsNaN<value_type>;
CHECK_EQ(isnan(extract(xsimd::max(T(val0), T(valN)))), isnan(std::max(val0, valN)));
CHECK_EQ(isnan(extract(xsimd::max(T(valN), T(val0)))), isnan(std::max(valN, val0)));
#endif
}

void test_min_nan()
{
value_type val0(2.7818);
value_type valN(NAN);
#if XSIMD_WITH_AVX || XSIMD_WITH_SSE2
using isnan = doctest::IsNaN<value_type>;
CHECK_EQ(isnan(extract(xsimd::min(T(val0), T(valN)))), isnan(std::min(val0, valN)));
CHECK_EQ(isnan(extract(xsimd::min(T(valN), T(val0)))), isnan(std::min(valN, val0)));
#endif
}

void test_nearbyint()
{
value_type val(3.1);
Expand Down Expand Up @@ -929,6 +952,16 @@ TEST_CASE_TEMPLATE("[xsimd api | float types functions]", B, FLOAT_TYPES)
Test.test_log1p();
}

SUBCASE("max_nan")
{
Test.test_max_nan();
}

SUBCASE("min_nan")
{
Test.test_min_nan();
}

SUBCASE("nearbyint")
{
Test.test_nearbyint();
Expand Down