1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

Change utils::popcnt16 to popcnt32

Use __builtin_popcount if available.
This commit is contained in:
Nekotekina 2019-06-02 00:16:41 +03:00
parent dfd50d0185
commit 0333942795
2 changed files with 13 additions and 10 deletions

View File

@ -52,18 +52,21 @@ namespace utils
#endif #endif
} }
inline u8 popcnt16(u16 arg) inline u8 popcnt32(u32 arg)
{ {
const u32 a1 = arg & 0x5555; #ifdef _MSC_VER
const u32 a2 = (arg >> 1) & 0x5555; const u32 a1 = arg & 0x55555555;
const u32 a2 = (arg >> 1) & 0x55555555;
const u32 a3 = a1 + a2; const u32 a3 = a1 + a2;
const u32 b1 = a3 & 0x3333; const u32 b1 = a3 & 0x33333333;
const u32 b2 = (a3 >> 2) & 0x3333; const u32 b2 = (a3 >> 2) & 0x33333333;
const u32 b3 = b1 + b2; const u32 b3 = b1 + b2;
const u32 c1 = b3 & 0x0f0f; const u32 c3 = (b3 + (b3 >> 4)) & 0x0f0f0f0f;
const u32 c2 = (b3 >> 4) & 0x0f0f; const u32 d3 = c3 + (c3 >> 8);
const u32 c3 = c1 + c2; return static_cast<u8>(d3 + (d3 >> 16));
return static_cast<u8>(c3 + (c3 >> 8)); #else
return __builtin_popcount(arg);
#endif
} }
// Rotate helpers // Rotate helpers

View File

@ -267,7 +267,7 @@ void cond_x16::imp_notify() noexcept
return; return;
} }
balanced_awaken<true>(m_cvx16, utils::popcnt16(wait_mask)); balanced_awaken<true>(m_cvx16, utils::popcnt32(wait_mask));
} }
bool lf_queue_base::wait(u64 _timeout) bool lf_queue_base::wait(u64 _timeout)