mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
improve granularity of custom compat_ctz
This commit is contained in:
parent
78ab9853a7
commit
98ea2b6a47
@ -66,17 +66,31 @@ static INLINE int compat_ctz(unsigned x)
|
||||
_BitScanForward((unsigned long*)&r, x);
|
||||
return (int)r;
|
||||
#else
|
||||
/* Only checks at nibble granularity,
|
||||
* because that's what we need. */
|
||||
if (x & 0x000f)
|
||||
return 0;
|
||||
if (x & 0x00f0)
|
||||
return 4;
|
||||
if (x & 0x0f00)
|
||||
return 8;
|
||||
if (x & 0xf000)
|
||||
return 12;
|
||||
return 16;
|
||||
int count = 0;
|
||||
if (!(x & 0xffff))
|
||||
{
|
||||
x >>= 16;
|
||||
count |= 16;
|
||||
}
|
||||
if (!(x & 0xff))
|
||||
{
|
||||
x >>= 8;
|
||||
count |= 8;
|
||||
}
|
||||
if (!(x & 0xf))
|
||||
{
|
||||
x >>= 4;
|
||||
count |= 4;
|
||||
}
|
||||
if (!(x & 0x3))
|
||||
{
|
||||
x >>= 2;
|
||||
count |= 2;
|
||||
}
|
||||
if (!(x & 0x1))
|
||||
count |= 1;
|
||||
|
||||
return count;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user