1 | /* Copyright (C) 2013-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_CORE_SHUFFLV1_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_SHUFFLV1_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/insn/shuffle2x2.h> |
17 | |
18 | namespace simdpp { |
19 | namespace SIMDPP_ARCH_NAMESPACE { |
20 | |
21 | /** Selects 64-bit values from two vectors. The first value in |
22 | each pair of values must come from @a a, the second - from @a b. The |
23 | selector values must be in range [0; 1]. |
24 | |
25 | @code |
26 | r0 = a[s0] |
27 | r1 = b[s1] |
28 | |
29 | 256-bit version: |
30 | r2 = a[s0+2] |
31 | r3 = b[s1+2] |
32 | @endcode |
33 | |
34 | @par floating-point |
35 | @par 128-bit version: |
36 | @novec{NEON, ALTIVEC} |
37 | |
38 | @par 256-bit version: |
39 | @icost{SSE2-SSE4.1, 2} |
40 | @novec{NEON, ALTIVEC} |
41 | |
42 | @par integer |
43 | @par 128-bit version: |
44 | @icost{ALTIVEC, 1-2} |
45 | |
46 | @par 256-bit version: |
47 | @icost{SSE2-AVX, 2} |
48 | @icost{NEON, 1-2} |
49 | @icost{ALTIVEC, 2-3} |
50 | */ |
51 | template<unsigned s0, unsigned s1, unsigned N, class V1, class V2> SIMDPP_INL |
52 | typename detail::get_expr2_nomask<V1, V2>::empty |
53 | shuffle1(const any_vec64<N,V1>& a, const any_vec64<N,V2>& b) |
54 | { |
55 | static_assert(s0 < 2 && s1 < 2, "Selector out of range" ); |
56 | typename detail::get_expr2_nomask<V1, V2>::type ra = a.wrapped().eval(), |
57 | rb = b.wrapped().eval(); |
58 | return detail::insn::i_shuffle2x2<s0,s1+2>(ra, rb); |
59 | } |
60 | |
61 | } // namespace SIMDPP_ARCH_NAMESPACE |
62 | } // namespace simdpp |
63 | |
64 | #endif |
65 | |
66 | |