Finish splitting m_core_clz into m_core_clz32 & m_core_clz64
This commit is contained in:
1 parent
8c34f44dae
commit
b5f4f2fc4b
4 files changed
+6
-5
No files matched your search
@@ -3764,7 +3764,8 @@ n shall be within 1 and the number of bits of the type minus 1.
|
||||
|
||||
Round to the next highest power of 2.
|
||||
|
||||
##### unsigned int m_core_clz(unsigned long limb)
|
||||
##### unsigned int m_core_clz32(uint32\_t limb)
|
||||
##### unsigned int m_core_clz64(uint64\_t limb)
|
||||
|
||||
Count the number of leading zero and return it.
|
||||
limb can be 0.
|
||||
|
||||
@@ -641,7 +641,7 @@
|
||||
assert (size > 1); \
|
||||
/* Let's select the threshold of the pass 1 to be sure \
|
||||
the final result is in tab.*/ \
|
||||
if (m_core_clz(size-1) & 1) \
|
||||
if (m_core_clz64(size-1) & 1) \
|
||||
th += th; \
|
||||
\
|
||||
/* Pass 1: insertion sort (stable) */ \
|
||||
|
||||
@@ -1277,7 +1277,7 @@ static inline uint64_t m_core_roundpow2(uint64_t v)
|
||||
|
||||
/* Return the count leading zero of the argument */
|
||||
#if defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__) >= 304
|
||||
static inline unsigned int m_core_clz(uint32_t limb)
|
||||
static inline unsigned int m_core_clz32(uint32_t limb)
|
||||
{
|
||||
return M_UNLIKELY (limb == 0) ? sizeof(uint32_t)*CHAR_BIT : __builtin_clzl(limb) - (sizeof(unsigned long) - sizeof(uint32_t)) * CHAR_BIT;
|
||||
}
|
||||
@@ -1288,7 +1288,7 @@ static inline unsigned int m_core_clz64(uint64_t limb)
|
||||
#else
|
||||
#define M_CORE_CLZ_TAB "\010\07\06\06\05\05\05\05\04\04\04\04\04\04\04\04\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
|
||||
|
||||
static inline unsigned int m_core_clz(uint32_t limb)
|
||||
static inline unsigned int m_core_clz32(uint32_t limb)
|
||||
{
|
||||
unsigned int shift = 0;
|
||||
/* This code should be branchless on most targets */
|
||||
|
||||
+1
-1
@@ -861,7 +861,7 @@ typedef unsigned int string_unicode_t;
|
||||
static inline void stringi_utf8_decode(char c, stringi_utf8_state_e *state,
|
||||
string_unicode_t *unicode)
|
||||
{
|
||||
const int type = m_core_clz((unsigned char)~c) - (sizeof(uint32_t) - 1) * CHAR_BIT;
|
||||
const int type = m_core_clz32((unsigned char)~c) - (sizeof(uint32_t) - 1) * CHAR_BIT;
|
||||
const string_unicode_t mask1 = -(string_unicode_t)(*state != STRINGI_UTF8_STARTING);
|
||||
const string_unicode_t mask2 = (0xFFU >> type);
|
||||
*unicode = ((*unicode << 6) & mask1) | (c & mask2);
|
||||
|
||||
Reference in new issue
Block a user