mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
Optimize COUNT_ZERO_MSBS macro
Reorder the conditions according to the expected distribution of input signal. This seems to make it almost as fast as the clz builtin using the bsr instruction. Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
committed by
Erik de Castro Lopo
parent
d9fde55674
commit
5289b309cf
@@ -68,9 +68,11 @@ COUNT_ZERO_MSBS (uint32_t word)
|
|||||||
#else
|
#else
|
||||||
/* counts the # of zero MSBs in a word */
|
/* counts the # of zero MSBs in a word */
|
||||||
#define COUNT_ZERO_MSBS(word) ( \
|
#define COUNT_ZERO_MSBS(word) ( \
|
||||||
(word) <= 0xffff ? \
|
(word) > 0xffffff ? byte_to_unary_table[(word) >> 24] : \
|
||||||
( (word) <= 0xff? byte_to_unary_table[word] + 24 : byte_to_unary_table[(word) >> 8] + 16 ) : \
|
!(word) ? 32 : \
|
||||||
( (word) <= 0xffffff? byte_to_unary_table[word >> 16] + 8 : byte_to_unary_table[(word) >> 24] ) \
|
(word) > 0xffff ? byte_to_unary_table[(word) >> 16] + 8 : \
|
||||||
|
(word) > 0xff ? byte_to_unary_table[(word) >> 8] + 16 : \
|
||||||
|
byte_to_unary_table[(word)] + 24 \
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user