Use builtin CLZ

Signed-off-by: Kevin Bracey <kevin.bracey@arm.com>
This commit is contained in:
Kevin Bracey 2020-10-06 12:25:28 +03:00
parent 3be252e252
commit 99c64e142e

View File

@ -424,9 +424,13 @@ bitcount_t uECC_vli_numBits(const uECC_word_t *vli)
}
digit = vli[num_digits - 1];
#if defined __GNUC__ || defined __clang__ || defined __CC_ARM
i = uECC_WORD_BITS - __builtin_clz(digit);
#else
for (i = 0; digit; ++i) {
digit >>= 1;
}
#endif
return (((bitcount_t)(num_digits - 1) << uECC_WORD_BITS_SHIFT) + i);
}