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 <robertphillips@google.com> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
18fdfe83a5
commit
cb8e5b28f0
@ -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 <intrin.h>
|
||||
|
||||
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<bool>(info[kECX] & kPopCntBit);
|
||||
}();
|
||||
|
||||
if (kHasPopCnt) {
|
||||
return __popcnt(n);
|
||||
} else {
|
||||
return SkPopCount_portable(n);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t SkSafeMath::Add(size_t x, size_t y) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user