Signed-off-by: James Almer <jamr...@gmail.com> --- I decided to go the configure route since other features (cmov, clz) also do it , but if prefered this could instead be done with a new intmath.h header in the x86/ folder containing something like
#if defined(__GNUC__) && defined(__POPCNT__) #define av_popcount __builtin_popcount #if ARCH_X86_64 #define av_popcount64 __builtin_popcountll #endif #endif For a cleaner compile time check. configure | 12 ++++++++++-- libavutil/intmath.h | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d037da1..3f1c394 100755 --- a/configure +++ b/configure @@ -1610,6 +1610,7 @@ ARCH_FEATURES=" fast_64bit fast_clz fast_cmov + fast_popcnt local_aligned_8 local_aligned_16 local_aligned_32 @@ -3908,13 +3909,20 @@ elif enabled x86; then cpuflags="-march=$cpu" disable i686 ;; - # targets that do support nopl and conditional mov (cmov) + # targets that do support nopl and conditional mov (cmov) but not popcnt i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\ - |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*) + |core2*|atom|bonnell) cpuflags="-march=$cpu" enable i686 enable fast_cmov ;; + # targets that do support nopl, conditional mov (cmov) and popcnt + core-*|corei*|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*) + cpuflags="-march=$cpu" + enable i686 + enable fast_cmov + enable fast_popcnt + ;; # targets that do support conditional mov but on which it's slow pentium4|pentium4m|prescott|nocona) cpuflags="-march=$cpu" diff --git a/libavutil/intmath.h b/libavutil/intmath.h index fa549c8..e95eced 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -53,6 +53,19 @@ #endif #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */ +#if HAVE_FAST_POPCNT +#if AV_GCC_VERSION_AT_LEAST(4,5) +#ifndef av_popcount + #define av_popcount __builtin_popcount +#endif /* av_popcount */ +#if HAVE_FAST_64BIT +#ifndef av_popcount64 + #define av_popcount64 __builtin_popcountll +#endif /* av_popcount64 */ +#endif /* HAVE_FAST_64BIT */ +#endif /* AV_GCC_VERSION_AT_LEAST(4,5) */ +#endif /* HAVE_FAST_POPCNT */ + extern const uint8_t ff_log2_tab[256]; #ifndef ff_log2 -- 2.3.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel