/* Copyright (C) 2013-2014 Povilas Kanapickas Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef LIBSIMDPP_SIMDPP_CORE_I_MUL_H #define LIBSIMDPP_SIMDPP_CORE_I_MUL_H #ifndef LIBSIMDPP_SIMD_H #error "This file must be included through simd.h" #endif #include #include #include #include #include namespace simdpp { namespace SIMDPP_ARCH_NAMESPACE { // no 8 bit multiplications in SSE /** Multiplies 16-bit values and returns the lower part of the multiplication @code r0 = low(a0 * b0) ... rN = low(aN * bN) @endcode @par 256-bit version: @icost{SSE2-AVX, NEON, ALTIVEC, 2} */ template SIMDPP_INL typename detail::get_expr_uint::type mul_lo(const any_int16& a, const any_int16& b) { return { { a.wrapped(), b.wrapped() } }; } SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(mul_lo, expr_mul_lo, any_int16, int16) /** Multiplies signed 16-bit values and returns the higher half of the result. @code r0 = high(a0 * b0) ... rN = high(aN * bN) @endcode @par 128-bit version: @icost{NEON, ALTIVEC, 3} @par 256-bit version: @icost{SSE2-AVX, 2} @icost{NEON, ALTIVEC, 6} */ template SIMDPP_INL int16, int16>> mul_hi(const int16& a, const int16& b) { return { { a, b } }; } SIMDPP_SCALAR_ARG_IMPL_EXPR(mul_hi, expr_mul_hi, int16, int16) /** Multiplies unsigned 16-bit values and returns the higher half of the result. @code r0 = high(a0 * b0) ... rN = high(aN * bN) @endcode @par 128-bit version: @icost{NEON, ALTIVEC, 3} @par 256-bit version: @icost{SSE2-AVX, 2} @icost{NEON, ALTIVEC, 6} */ template SIMDPP_INL uint16, uint16>> mul_hi(const uint16& a, const uint16& b) { return { { a, b } }; } SIMDPP_SCALAR_ARG_IMPL_EXPR(mul_hi, expr_mul_hi, uint16, uint16) /** Multiplies 32-bit values and returns the lower half of the result. @code r0 = low(a0 * b0) ... rN = low(aN * bN) @endcode @par 128-bit version: @icost{SSE2-SSSE3, 6} @icost{ALTIVEC, 8} @par 256-bit version: @icost{SSE2-SSSE3, 12} @icost{SSE4.1, AVX, NEON, 2} @icost{ALTIVEC, 16} */ template SIMDPP_INL typename detail::get_expr_uint::type mul_lo(const any_int32& a, const any_int32& b) { return { { a.wrapped(), b.wrapped() } }; } SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(mul_lo, expr_mul_lo, any_int32, int32) } // namespace SIMDPP_ARCH_NAMESPACE } // namespace simdpp #endif