commit | 99c64e142eadb8823190f84a6547da8e9c3504ae | [log] [tgz] |
---|---|---|
author | Kevin Bracey <kevin.bracey@arm.com> | Tue Oct 06 12:25:28 2020 +0300 |
committer | Kevin Bracey <kevin.bracey@arm.com> | Mon Oct 12 18:09:04 2020 +0300 |
tree | d5df47d195f40906d5e97b99418da6c5ecf91c13 | |
parent | 3be252e252ef648a6c763162956f0213c732c884 [diff] [blame] |
Use builtin CLZ Signed-off-by: Kevin Bracey <kevin.bracey@arm.com>
diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c index ee91957..3407aaf 100644 --- a/tinycrypt/ecc.c +++ b/tinycrypt/ecc.c
@@ -424,9 +424,13 @@ } 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); }