1/* Copyright (C) 2011-2014 Povilas Kanapickas <povilas@radix.lt>
2
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8#ifndef LIBSIMDPP_SIMDPP_DETAIL_INSN_F_MIN_H
9#define LIBSIMDPP_SIMDPP_DETAIL_INSN_F_MIN_H
10
11#ifndef LIBSIMDPP_SIMD_H
12 #error "This file must be included through simd.h"
13#endif
14
15#include <simdpp/types.h>
16#include <simdpp/detail/null/math.h>
17#include <simdpp/detail/vector_array_macros.h>
18
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21namespace detail {
22namespace insn {
23
24
25static SIMDPP_INL
26float32x4 i_min(const float32x4& a, const float32x4& b)
27{
28#if SIMDPP_USE_NULL || SIMDPP_USE_NEON_NO_FLT_SP
29 return detail::null::min(a, b);
30#elif SIMDPP_USE_SSE2
31 return _mm_min_ps(a.native(), b.native());
32#elif SIMDPP_USE_NEON
33 return vminq_f32(a.native(), b.native());
34#elif SIMDPP_USE_ALTIVEC
35 return vec_min(a.native(), b.native());
36#elif SIMDPP_USE_MSA
37 return __msa_fmin_w(a.native(), b.native());
38#endif
39}
40
41#if SIMDPP_USE_AVX
42static SIMDPP_INL
43float32x8 i_min(const float32x8& a, const float32x8& b)
44{
45 return _mm256_min_ps(a.native(), b.native());
46}
47#endif
48
49#if SIMDPP_USE_AVX512F
50static SIMDPP_INL
51float32<16> i_min(const float32<16>& a, const float32<16>& b)
52{
53 return _mm512_min_ps(a.native(), b.native());
54}
55#endif
56
57template<unsigned N> SIMDPP_INL
58float32<N> i_min(const float32<N>& a, const float32<N>& b)
59{
60 SIMDPP_VEC_ARRAY_IMPL2(float32<N>, i_min, a, b);
61}
62
63// -----------------------------------------------------------------------------
64
65static SIMDPP_INL
66float64x2 i_min(const float64x2& a, const float64x2& b)
67{
68#if SIMDPP_USE_SSE2
69 return _mm_min_pd(a.native(), b.native());
70#elif SIMDPP_USE_NEON64
71 return vminq_f64(a.native(), b.native());
72#elif SIMDPP_USE_VSX_206
73 return vec_min(a.native(), b.native());
74#elif SIMDPP_USE_MSA
75 return __msa_fmin_d(a.native(), b.native());
76#elif SIMDPP_USE_NULL || SIMDPP_USE_NEON32 || SIMDPP_USE_ALTIVEC
77 return detail::null::min(a, b);
78#endif
79}
80
81#if SIMDPP_USE_AVX
82static SIMDPP_INL
83float64x4 i_min(const float64x4& a, const float64x4& b)
84{
85 return _mm256_min_pd(a.native(), b.native());
86}
87#endif
88
89#if SIMDPP_USE_AVX512F
90static SIMDPP_INL
91float64<8> i_min(const float64<8>& a, const float64<8>& b)
92{
93 return _mm512_min_pd(a.native(), b.native());
94}
95#endif
96
97template<unsigned N> SIMDPP_INL
98float64<N> i_min(const float64<N>& a, const float64<N>& b)
99{
100 SIMDPP_VEC_ARRAY_IMPL2(float64<N>, i_min, a, b);
101}
102
103
104} // namespace insn
105} // namespace detail
106} // namespace SIMDPP_ARCH_NAMESPACE
107} // namespace simdpp
108
109#endif
110
111