From: Philip Pronin Date: Mon, 9 May 2016 07:06:57 +0000 (-0700) Subject: Reverted commit D3265572 X-Git-Tag: 2016.07.26~266 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0759dee48fca5973414d86505c8cd2ea82ec3a39;p=folly.git Reverted commit D3265572 Summary: I would switch these to just use the intrinsic functions, but GCC 4.8 doesn't support them. MSVC supports the intrinsics, which is the primary reason for the switch. Reviewed By: yfeldblum Differential Revision: D3265572 fb-gh-sync-id: 3268f90d5234bdf77b3579504efd3dcd43f38aff fbshipit-source-id: 3268f90d5234bdf77b3579504efd3dcd43f38aff --- diff --git a/folly/Portability.h b/folly/Portability.h index cbf1b71c..c9616ea7 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -92,13 +92,6 @@ constexpr bool kHasUnalignedAccess = false; # define FOLLY_ALWAYS_INLINE inline #endif -// target -#ifdef _MSC_VER -# define FOLLY_TARGET_ATTRIBUTE(target) -#else -# define FOLLY_TARGET_ATTRIBUTE(target) __attribute__((__target__(target))) -#endif - // detection for 64 bit #if defined(__x86_64__) || defined(_M_X64) # define FOLLY_X64 1 diff --git a/folly/experimental/Instructions.h b/folly/experimental/Instructions.h index 6a1d6ed6..97386ff1 100644 --- a/folly/experimental/Instructions.h +++ b/folly/experimental/Instructions.h @@ -17,10 +17,8 @@ #pragma once #include -#include #include -#include namespace folly { namespace compression { namespace instructions { @@ -54,17 +52,11 @@ struct Nehalem : public Default { static bool supported(const folly::CpuId& cpuId = {}) { return cpuId.popcnt(); } - static inline uint64_t popcount(uint64_t value) - FOLLY_TARGET_ATTRIBUTE("popcnt") { + static inline uint64_t popcount(uint64_t value) { // POPCNT is supported starting with Intel Nehalem, AMD K10. -#if defined(__GNUC__) && !__GNUC_PREREQ(4, 9) - // GCC 4.8 doesn't support the intrinsics. uint64_t result; asm ("popcntq %1, %0" : "=r" (result) : "r" (value)); return result; -#else - return _mm_popcnt_u64(value); -#endif } }; @@ -72,17 +64,12 @@ struct Haswell : public Nehalem { static bool supported(const folly::CpuId& cpuId = {}) { return Nehalem::supported(cpuId) && cpuId.bmi1(); } - static inline uint64_t blsr(uint64_t value) FOLLY_TARGET_ATTRIBUTE("bmi") { + static inline uint64_t blsr(uint64_t value) { // BMI1 is supported starting with Intel Haswell, AMD Piledriver. // BLSR combines two instuctions into one and reduces register pressure. -#if defined(__GNUC__) && !__GNUC_PREREQ(4, 9) - // GCC 4.8 doesn't support the intrinsics. uint64_t result; asm ("blsrq %1, %0" : "=r" (result) : "r" (value)); return result; -#else - return _blsr_u64(value); -#endif } }; diff --git a/folly/experimental/Select64.h b/folly/experimental/Select64.h index 5d0fcaa5..9c2e03f9 100644 --- a/folly/experimental/Select64.h +++ b/folly/experimental/Select64.h @@ -62,15 +62,9 @@ inline uint64_t select64(uint64_t x, uint64_t k) { return place + detail::kSelectInByte[((x >> place) & 0xFF) | (byteRank << 8)]; } -template <> -uint64_t select64(uint64_t x, uint64_t k) - FOLLY_TARGET_ATTRIBUTE("bmi,bmi2"); - template <> inline uint64_t select64(uint64_t x, uint64_t k) { -#if defined(__GNUC__) && !__GNUC_PREREQ(4, 9) - // GCC 4.8 doesn't support the intrinsics. uint64_t result = uint64_t(1) << k; asm("pdep %1, %0, %0\n\t" @@ -79,9 +73,6 @@ inline uint64_t select64(uint64_t x, : "r"(x)); return result; -#else - return _tzcnt_u64(_pdep_u64(x, 1ULL << k)); -#endif } } // namespace folly