// Matrix Construct // // Copyright (C) Matrix Construct Developers, Authors & Contributors // Copyright (C) 2016-2021 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. #pragma once #define HAVE_IRCD_SIMD_PACK_H // Pack values left overwriting unmasked lanes. namespace ircd::simd { template T pack(const T vals, const U mask) noexcept; } /// Left-pack values to eliminate unmasked lanes. /// TODO: WIP template inline T ircd::simd::pack(const T val, const U mask) noexcept { static_assert ( lanes() == lanes() ); static_assert ( std::is_integral>() ); U idx{0}, add(mask & 1); for(uint i(0); i < lanes(); ++i) { add = shl() * 8L>(add); idx += add; } return shuf(val, idx); }