load_packed2.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (C) 2013-2014 Povilas Kanapickas <[email protected]>
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef LIBSIMDPP_SIMDPP_CORE_LOAD_PACKED2_H
  7. #define LIBSIMDPP_SIMDPP_CORE_LOAD_PACKED2_H
  8. #ifndef LIBSIMDPP_SIMD_H
  9. #error "This file must be included through simd.h"
  10. #endif
  11. #include <simdpp/types.h>
  12. #include <simdpp/detail/insn/load_packed2.h>
  13. #include <simdpp/detail/traits.h>
  14. namespace simdpp {
  15. namespace SIMDPP_ARCH_NAMESPACE {
  16. /** Loads values packed in pairs, de-interleaves them and stores the result
  17. into two vectors.
  18. @code
  19. a = [ *(p), *(p+2), *(p+4), ... , *(p+M*2-2) ]
  20. b = [ *(p+1), *(p+3), *(p+5), ... , *(p+M*2-1) ]
  21. @endcode
  22. Here M is the number of elements in the vector
  23. @a p must be aligned to the vector size in bytes
  24. */
  25. template<unsigned N, class V, class T> SIMDPP_INL
  26. void load_packed2(any_vec<N,V>& a, any_vec<N,V>& b, const T* p)
  27. {
  28. static_assert(!is_mask<V>::value, "Mask types can not be loaded");
  29. typename detail::get_expr_nosign<V>::type ra, rb;
  30. detail::insn::i_load_packed2(ra, rb, reinterpret_cast<const char*>(p));
  31. a.wrapped() = ra;
  32. b.wrapped() = rb;
  33. }
  34. } // namespace SIMDPP_ARCH_NAMESPACE
  35. } // namespace simdpp
  36. #endif