From cb8e5b28f0200ef4bfe7be7a7406f7c845f2c45a Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Wed, 1 Jun 2022 16:21:00 -0400 Subject: [PATCH] Remove MSVC __popcnt intrinsic special casing MSVC is a very marginal compiler for us (and we don't call SkPopCount that often) so we've deemed it not worth the extra complexity to handle the __popcnt intrinsic. Change-Id: I1d838727eab503cd99a72d07e9787280d0948b29 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545896 Commit-Queue: Robert Phillips Reviewed-by: Herb Derby Reviewed-by: John Stiles --- src/core/SkMath.cpp | 22 ---------------------- src/core/SkMathPriv.h | 4 +--- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp index a7e3d5b314..78d87d8bb8 100644 --- a/src/core/SkMath.cpp +++ b/src/core/SkMath.cpp @@ -50,28 +50,6 @@ int SkPopCount_portable(uint32_t n) { return count; } -#if defined(SK_BUILD_FOR_WIN) && !defined(_M_ARM) && !defined(_M_ARM64) -#include - -int SkPopCount(uint32_t n) { - static const bool kHasPopCnt = [] { - static constexpr int kPopCntBit = 0x1 << 23; // Bit 23 is the popcnt feature bit in ECX - static constexpr int kECX = 2; - static constexpr int kProcessorInfoAndFeatureBits = 1; - - int info[4]; // contents of the EAX, EBX, ECX, and EDX registers, in that order - __cpuid(info, kProcessorInfoAndFeatureBits); - return static_cast(info[kECX] & kPopCntBit); - }(); - - if (kHasPopCnt) { - return __popcnt(n); - } else { - return SkPopCount_portable(n); - } -} -#endif - /////////////////////////////////////////////////////////////////////////////////////////////////// size_t SkSafeMath::Add(size_t x, size_t y) { diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h index 0091706c8f..7e9de45a61 100644 --- a/src/core/SkMathPriv.h +++ b/src/core/SkMathPriv.h @@ -136,9 +136,7 @@ static inline unsigned SkDiv255Round(unsigned prod) { */ int SkPopCount_portable(uint32_t n); -#if defined(SK_BUILD_FOR_WIN) && !defined(_M_ARM) && !defined(_M_ARM64) - int SkPopCount(uint32_t n); -#elif defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) || defined(__clang__) static inline int SkPopCount(uint32_t n) { return __builtin_popcount(n); }