Replace XOR with subtraction for readability
This commit is contained in:
+4
-4
@@ -60,7 +60,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
|||||||
val |= val >> 4;
|
val |= val >> 4;
|
||||||
val |= val >> 8;
|
val |= val >> 8;
|
||||||
val |= val >> 16;
|
val |= val >> 16;
|
||||||
return DeBruijnClz[(val * 0x07C4ACDDU) >> 27] ^ 31;
|
return 31 - DeBruijnClz[(val * 0x07C4ACDDU) >> 27];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
|||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
_BitScanReverse(&r, val);
|
_BitScanReverse(&r, val);
|
||||||
return (unsigned)(r ^ 31);
|
return (unsigned)(31 - r);
|
||||||
} else {
|
} else {
|
||||||
/* Should not reach this code path */
|
/* Should not reach this code path */
|
||||||
__assume(0);
|
__assume(0);
|
||||||
@@ -128,7 +128,7 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
|||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
unsigned long r;
|
unsigned long r;
|
||||||
_BitScanReverse64(&r, val);
|
_BitScanReverse64(&r, val);
|
||||||
return (unsigned)(r ^ 63);
|
return (unsigned)(63 - r);
|
||||||
} else {
|
} else {
|
||||||
/* Should not reach this code path */
|
/* Should not reach this code path */
|
||||||
__assume(0);
|
__assume(0);
|
||||||
@@ -169,7 +169,7 @@ MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
|
|||||||
MEM_STATIC unsigned ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
|
MEM_STATIC unsigned ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
|
||||||
{
|
{
|
||||||
assert(val != 0);
|
assert(val != 0);
|
||||||
return ZSTD_countLeadingZeros32(val) ^ 31;
|
return 31 - ZSTD_countLeadingZeros32(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ZSTD_BITS_H */
|
#endif /* ZSTD_BITS_H */
|
||||||
|
|||||||
+1
-1
@@ -3375,7 +3375,7 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
|||||||
}
|
}
|
||||||
DISPLAYLEVEL(3, "OK \n");
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
|
|
||||||
DISPLAYLEVEL(3, "test%3i : testing bitwise instrinsics PR#3045: ", testNb++);
|
DISPLAYLEVEL(3, "test%3i : testing bitwise intrinsics PR#3045: ", testNb++);
|
||||||
{
|
{
|
||||||
U32 seed_copy = seed; // need non-const seed to avoid compiler warning for FUZ_rand(&seed)
|
U32 seed_copy = seed; // need non-const seed to avoid compiler warning for FUZ_rand(&seed)
|
||||||
U32 rand32 = FUZ_rand(&seed_copy);
|
U32 rand32 = FUZ_rand(&seed_copy);
|
||||||
|
|||||||
Reference in New Issue
Block a user