From e466687f11c432e8ea8a6fe6e4a8092013b87539 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Wed, 31 Jul 2019 23:08:41 +0300 Subject: [PATCH] [Base] Fix tzcnt logic --- src/xenia/base/math.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xenia/base/math.h b/src/xenia/base/math.h index 091115d6e..8852636d2 100644 --- a/src/xenia/base/math.h +++ b/src/xenia/base/math.h @@ -128,28 +128,28 @@ inline uint8_t tzcnt(uint8_t v) { unsigned long index; unsigned long mask = v; unsigned char is_nonzero = _BitScanForward(&index, mask); - return static_cast(is_nonzero ? int8_t(index) ^ 0x7 : 8); + return static_cast(is_nonzero ? int8_t(index) : 8); } inline uint8_t tzcnt(uint16_t v) { unsigned long index; unsigned long mask = v; unsigned char is_nonzero = _BitScanForward(&index, mask); - return static_cast(is_nonzero ? int8_t(index) ^ 0xF : 16); + return static_cast(is_nonzero ? int8_t(index) : 16); } inline uint8_t tzcnt(uint32_t v) { unsigned long index; unsigned long mask = v; unsigned char is_nonzero = _BitScanForward(&index, mask); - return static_cast(is_nonzero ? int8_t(index) ^ 0x1F : 32); + return static_cast(is_nonzero ? int8_t(index) : 32); } inline uint8_t tzcnt(uint64_t v) { unsigned long index; unsigned long long mask = v; unsigned char is_nonzero = _BitScanForward64(&index, mask); - return static_cast(is_nonzero ? int8_t(index) ^ 0x3F : 64); + return static_cast(is_nonzero ? int8_t(index) : 64); } #else // XE_PLATFORM_WIN32