#ifndef MAD_BIT_SSE2_TC #define MAD_BIT_SSE2_TC /* o-----------------------------------------------------------------------------o | | SSE2 optimization for bit manipulation | | Methodical Accelerator Design - Copyright (c) 2016+ | Support: http://cern.ch/mad - mad at cern.ch | Authors: L. Deniau, laurent.deniau at cern.ch | Contrib: - | o-----------------------------------------------------------------------------o | You can redistribute this file and/or modify it under the terms of the GNU | General Public License GPLv3 (or later), as published by the Free Software | Foundation. This file is distributed in the hope that it will be useful, but | WITHOUT ANY WARRANTY OF ANY KIND. See http://gnu.org/licenses for details. o-----------------------------------------------------------------------------o */ #include static inline int __attribute__((const)) mad_bit_lowest32 (uint32_t b) { return b ? _bit_scan_forward(b) : 32; } static inline int __attribute__((const)) mad_bit_highest32 (uint32_t b) { return b ? _bit_scan_reverse(b) : -1; } static inline int __attribute__((const)) mad_bit_lowest64 (uint64_t b) { uint32_t lo = b & ~0u; return lo ? mad_bit_lowest32(lo) : 32+mad_bit_lowest32(b >> 32); } static inline int __attribute__((const)) mad_bit_highest64 (uint64_t b) { uint32_t hi = b >> 32; return hi ? 32+mad_bit_highest32(hi) : mad_bit_highest32(b & ~0u); } // --- end --------------------------------------------------------------------o #endif // MAD_MONO_SSE2_TC