Use clz ^ 31 instead of 31 - clz; better codegen for GCC

This commit is contained in:
Dávid Bolvanský
2019-09-23 21:23:09 +02:00
parent 7451c6578c
commit 1f7228c040
8 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -164,7 +164,7 @@ MEM_STATIC unsigned BIT_highbit32 (U32 val)
_BitScanReverse ( &r, val );
return (unsigned) r;
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
return 31 - __builtin_clz (val);
return __builtin_clz (val) ^ 31;
# elif defined(__ICCARM__) /* IAR Intrinsic */
return 31 - __CLZ(val);
# else /* Software version */