Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Vc/sse/deinterleave.tcc is written in an unsupported language. File is not indexed.

0001 /*  This file is part of the Vc library. {{{
0002 Copyright © 2010-2015 Matthias Kretz <kretz@kde.org>
0003 
0004 Redistribution and use in source and binary forms, with or without
0005 modification, are permitted provided that the following conditions are met:
0006     * Redistributions of source code must retain the above copyright
0007       notice, this list of conditions and the following disclaimer.
0008     * Redistributions in binary form must reproduce the above copyright
0009       notice, this list of conditions and the following disclaimer in the
0010       documentation and/or other materials provided with the distribution.
0011     * Neither the names of contributing organizations nor the
0012       names of its contributors may be used to endorse or promote products
0013       derived from this software without specific prior written permission.
0014 
0015 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
0016 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0017 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0018 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
0019 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0020 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0021 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0022 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0023 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0025 
0026 }}}*/
0027 
0028 namespace Vc_VERSIONED_NAMESPACE
0029 {
0030 namespace SSE
0031 {
0032 
0033 inline void deinterleave(Vector<float> &a, Vector<float> &b)
0034 {
0035     const __m128 tmp0 = _mm_unpacklo_ps(a.data(), b.data());
0036     const __m128 tmp1 = _mm_unpackhi_ps(a.data(), b.data());
0037     a.data() = _mm_unpacklo_ps(tmp0, tmp1);
0038     b.data() = _mm_unpackhi_ps(tmp0, tmp1);
0039 }
0040 
0041 inline void deinterleave(Vector<float> &a, Vector<float> &b, Vector<short>::AsArg tmp)
0042 {
0043     a.data() = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_slli_epi32(tmp.data(), 16), 16));
0044     b.data() = _mm_cvtepi32_ps(_mm_srai_epi32(tmp.data(), 16));
0045 }
0046 
0047 inline void deinterleave(Vector<float> &a, Vector<float> &b, Vector<unsigned short>::AsArg tmp)
0048 {
0049     a.data() = _mm_cvtepi32_ps(_mm_srli_epi32(_mm_slli_epi32(tmp.data(), 16), 16));
0050     b.data() = _mm_cvtepi32_ps(_mm_srli_epi32(tmp.data(), 16));
0051 }
0052 
0053 inline void deinterleave(Vector<double> &a, Vector<double> &b)
0054 {
0055     __m128d tmp = _mm_unpacklo_pd(a.data(), b.data());
0056     b.data() = _mm_unpackhi_pd(a.data(), b.data());
0057     a.data() = tmp;
0058 }
0059 
0060 inline void deinterleave(Vector<int> &a, Vector<int> &b)
0061 {
0062     const __m128i tmp0 = _mm_unpacklo_epi32(a.data(), b.data());
0063     const __m128i tmp1 = _mm_unpackhi_epi32(a.data(), b.data());
0064     a.data() = _mm_unpacklo_epi32(tmp0, tmp1);
0065     b.data() = _mm_unpackhi_epi32(tmp0, tmp1);
0066 }
0067 
0068 inline void deinterleave(Vector<unsigned int> &a, Vector<unsigned int> &b)
0069 {
0070     const __m128i tmp0 = _mm_unpacklo_epi32(a.data(), b.data());
0071     const __m128i tmp1 = _mm_unpackhi_epi32(a.data(), b.data());
0072     a.data() = _mm_unpacklo_epi32(tmp0, tmp1);
0073     b.data() = _mm_unpackhi_epi32(tmp0, tmp1);
0074 }
0075 
0076 inline void deinterleave(Vector<short> &a, Vector<short> &b)
0077 {
0078     __m128i tmp0 = _mm_unpacklo_epi16(a.data(), b.data()); // a0 a4 b0 b4 a1 a5 b1 b5
0079     __m128i tmp1 = _mm_unpackhi_epi16(a.data(), b.data()); // a2 a6 b2 b6 a3 a7 b3 b7
0080     __m128i tmp2 = _mm_unpacklo_epi16(tmp0, tmp1); // a0 a2 a4 a6 b0 b2 b4 b6
0081     __m128i tmp3 = _mm_unpackhi_epi16(tmp0, tmp1); // a1 a3 a5 a7 b1 b3 b5 b7
0082     a.data() = _mm_unpacklo_epi16(tmp2, tmp3);
0083     b.data() = _mm_unpackhi_epi16(tmp2, tmp3);
0084 }
0085 
0086 inline void deinterleave(Vector<unsigned short> &a, Vector<unsigned short> &b)
0087 {
0088     __m128i tmp0 = _mm_unpacklo_epi16(a.data(), b.data()); // a0 a4 b0 b4 a1 a5 b1 b5
0089     __m128i tmp1 = _mm_unpackhi_epi16(a.data(), b.data()); // a2 a6 b2 b6 a3 a7 b3 b7
0090     __m128i tmp2 = _mm_unpacklo_epi16(tmp0, tmp1); // a0 a2 a4 a6 b0 b2 b4 b6
0091     __m128i tmp3 = _mm_unpackhi_epi16(tmp0, tmp1); // a1 a3 a5 a7 b1 b3 b5 b7
0092     a.data() = _mm_unpacklo_epi16(tmp2, tmp3);
0093     b.data() = _mm_unpackhi_epi16(tmp2, tmp3);
0094 }
0095 
0096 inline void deinterleave(Vector<int> &a, Vector<int> &b, Vector<short>::AsArg tmp)
0097 {
0098     a.data() = _mm_srai_epi32(_mm_slli_epi32(tmp.data(), 16), 16);
0099     b.data() = _mm_srai_epi32(tmp.data(), 16);
0100 }
0101 
0102 inline void deinterleave(Vector<unsigned int> &a, Vector<unsigned int> &b, Vector<unsigned short>::AsArg tmp)
0103 {
0104     a.data() = _mm_srli_epi32(_mm_slli_epi32(tmp.data(), 16), 16);
0105     b.data() = _mm_srli_epi32(tmp.data(), 16);
0106 }
0107 
0108 }
0109 }
0110 namespace Vc_VERSIONED_NAMESPACE
0111 {
0112 namespace Detail
0113 {
0114 template<typename A> inline void deinterleave(
0115         SSE::float_v &a, SSE::float_v &b, const float *m, A align)
0116 {
0117     a.load(m, align);
0118     b.load(m + SSE::float_v::Size, align);
0119     Vc::SSE::deinterleave(a, b);
0120 }
0121 
0122 template<typename A> inline void deinterleave(
0123         SSE::float_v &a, SSE::float_v &b, const short *m, A align)
0124 {
0125     SSE::short_v tmp(m, align);
0126     Vc::SSE::deinterleave(a, b, tmp);
0127 }
0128 
0129 template<typename A> inline void deinterleave(
0130         SSE::float_v &a, SSE::float_v &b, const unsigned short *m, A align)
0131 {
0132     SSE::ushort_v tmp(m, align);
0133     Vc::SSE::deinterleave(a, b, tmp);
0134 }
0135 
0136 template<typename A> inline void deinterleave(
0137         SSE::double_v &a, SSE::double_v &b, const double *m, A align)
0138 {
0139     a.load(m, align);
0140     b.load(m + SSE::double_v::Size, align);
0141     Vc::SSE::deinterleave(a, b);
0142 }
0143 
0144 template<typename A> inline void deinterleave(
0145         SSE::int_v &a, SSE::int_v &b, const int *m, A align)
0146 {
0147     a.load(m, align);
0148     b.load(m + SSE::int_v::Size, align);
0149     Vc::SSE::deinterleave(a, b);
0150 }
0151 
0152 template<typename A> inline void deinterleave(
0153         SSE::int_v &a, SSE::int_v &b, const short *m, A align)
0154 {
0155     SSE::short_v tmp(m, align);
0156     Vc::SSE::deinterleave(a, b, tmp);
0157 }
0158 
0159 template<typename A> inline void deinterleave(
0160         SSE::uint_v &a, SSE::uint_v &b, const unsigned int *m, A align)
0161 {
0162     a.load(m, align);
0163     b.load(m + SSE::uint_v::Size, align);
0164     Vc::SSE::deinterleave(a, b);
0165 }
0166 
0167 template<typename A> inline void deinterleave(
0168         SSE::uint_v &a, SSE::uint_v &b, const unsigned short *m, A align)
0169 {
0170     SSE::ushort_v tmp(m, align);
0171     Vc::SSE::deinterleave(a, b, tmp);
0172 }
0173 
0174 template<typename A> inline void deinterleave(
0175         SSE::short_v &a, SSE::short_v &b, const short *m, A align)
0176 {
0177     a.load(m, align);
0178     b.load(m + SSE::short_v::Size, align);
0179     Vc::SSE::deinterleave(a, b);
0180 }
0181 
0182 template<typename A> inline void deinterleave(
0183         SSE::ushort_v &a, SSE::ushort_v &b, const unsigned short *m, A align)
0184 {
0185     a.load(m, align);
0186     b.load(m + SSE::ushort_v::Size, align);
0187     Vc::SSE::deinterleave(a, b);
0188 }
0189 }  // namespace Detail
0190 }  // namespace Vc