ppcopcodes: fix cntlzw to compile properly with Clang.

Enable USE_GCC_BUILTINS by default.
This commit is contained in:
Maxim Poliakovski 2020-12-18 18:31:05 +01:00
parent 99641b1b5e
commit dbbaf13a78
2 changed files with 6 additions and 5 deletions

View File

@ -35,7 +35,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
//#define ILLEGAL_OP_SAFE 1 //#define ILLEGAL_OP_SAFE 1
// Uncomment this to use GCC built-in functions. // Uncomment this to use GCC built-in functions.
//#define USE_GCC_BUILTINS 1 #define USE_GCC_BUILTINS 1
// Uncomment this to use Visual Studio built-in functions. // Uncomment this to use Visual Studio built-in functions.
//#define USE_VS_BUILTINS 1 //#define USE_VS_BUILTINS 1

View File

@ -516,15 +516,16 @@ void dppc_interpreter::ppc_neg() {
void dppc_interpreter::ppc_cntlzw() { void dppc_interpreter::ppc_cntlzw() {
ppc_grab_regssa(); ppc_grab_regssa();
uint32_t lead;
uint32_t bit_check = ppc_result_d; uint32_t bit_check = ppc_result_d;
#ifdef USE_GCC_BUILTINS #ifdef USE_GCC_BUILTINS
lead = !bit_check ? 32 : __builtin_clz(bit_check); uint32_t lead = !bit_check ? 32 : __builtin_clz(bit_check);
#elif defined USE_VS_BUILTINS #elif defined USE_VS_BUILTINS
lead = __lzcnt(bit_check); uint32_t lead = __lzcnt(bit_check);
#else #else
for (uint32_t mask = 0x80000000UL, lead = 0; mask; lead++, mask >>= 1) { uint32_t lead, mask;
for (mask = 0x80000000UL, lead = 0; mask != 0; lead++, mask >>= 1) {
if (bit_check & mask) if (bit_check & mask)
break; break;
} }