File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -47,28 +47,28 @@ __forceinline size_t SAFE_SHIFT_RIGHT(size_t x, size_t count)
47
47
48
48
inline UINT32 CeilOfLog2 (size_t x )
49
49
{
50
- // we want lzcnt, but bsr is ok too
50
+ // it is ok to use bsr or clz unconditionally
51
51
_ASSERTE (x > 0 );
52
52
53
53
x = (x << 1 ) - 1 ;
54
54
55
55
#ifdef TARGET_64BIT
56
56
#ifdef _MSC_VER
57
- DWORD lzcountCeil ;
58
- _BitScanReverse64 (& lzcountCeil , (unsigned long )x );
57
+ DWORD result ;
58
+ _BitScanReverse64 (& result , (unsigned long )x );
59
+ return (UINT32 )result ;
59
60
#else // _MSC_VER
60
- UINT32 lzcountCeil = (UINT32 )__builtin_clzl ((unsigned long )x );
61
+ return BITS_PER_SIZE_T - (UINT32 )__builtin_clzl ((unsigned long )x );
61
62
#endif // _MSC_VER
62
63
#else // TARGET_64BIT
63
64
#ifdef _MSC_VER
64
- DWORD lzcountCeil ;
65
- _BitScanReverse (& lzcountCeil , (unsigned long )x );
65
+ DWORD result ;
66
+ _BitScanReverse (& result , (unsigned int )x );
67
+ return (UINT32 )result ;
66
68
#else // _MSC_VER
67
- UINT32 lzcountCeil = (UINT32 )__builtin_clz ((unsigned int )x );
69
+ return BITS_PER_SIZE_T - (UINT32 )__builtin_clz ((unsigned int )x );
68
70
#endif // _MSC_VER
69
71
#endif
70
-
71
- return BITS_PER_SIZE_T - lzcountCeil ;
72
72
}
73
73
74
74
enum GcSlotFlags
You can’t perform that action at this time.
0 commit comments