[FFmpeg-devel] [PATCH 1/2] lavu/intmath.h: Add msvc/icl ctzll optimisations.
James Almer
jamrial at gmail.com
Thu Oct 15 18:47:56 CEST 2015
On 10/15/2015 11:07 AM, Matt Oliver wrote:
> This patch just adds the msvc and icl equivalent ctzll optimisations to
> correspond with the recently added gcc variant
>
>
> 0001-lavu-intmath.h-Add-msvc-icl-ctzll-optimisations.patch
>
>
> From 2b8e7757cdb8595181a01bb18756d60662c41fde Mon Sep 17 00:00:00 2001
> From: Matt Oliver <protogonoi at gmail.com>
> Date: Thu, 15 Oct 2015 19:42:31 +1100
> Subject: [PATCH 1/2] lavu/intmath.h: Add msvc/icl ctzll optimisations.
>
> Signed-off-by: Matt Oliver <protogonoi at gmail.com>
> ---
> libavutil/x86/intmath.h | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
> index fefad20..613903b 100644
> --- a/libavutil/x86/intmath.h
> +++ b/libavutil/x86/intmath.h
> @@ -60,6 +60,34 @@ static av_always_inline av_const unsigned av_mod_uintp2_bmi2(unsigned a, unsigne
>
> #endif /* __BMI2__ */
>
> +#elif defined(_MSC_VER)
Don't use elif if this code is also supposed to work on icl. That compiler defines __GNUC__.
> +#define ff_ctzll ff_ctzll_c
> +static av_always_inline av_const int ff_ctzll_c(long long v)
nit: ff_ctzll_x86 for the inline version. And you need to check HAVE_INLINE_ASM for it as
well.
> +{
> +#if defined(__INTEL_COMPILER)
> +#if ARCH_X86_64
> + uint64_t c;
> + __asm__("bsfq %1,%0" : "=r" (c) : "r" (v));
> + return c;
> +#else
> + return ((uint32_t)v == 0) ? _bit_scan_forward(((uint32_t *)&v)[1]) + 32 : _bit_scan_forward((uint32_t)v);
(uint32_t)(v >> 32)
> +#endif
> +#else
> + unsigned long c;
> +#if ARCH_X86_64
> + _BitScanForward64(&c, v);
> +#else
> + if ((uint32_t)v == 0) {
> + _BitScanForward(&c, ((uint32_t *)&v)[1]);
Same
> + c += 32;
> + } else {
> + _BitScanForward(&c, (uint32_t)v);
> + }
> +#endif
> + return c;
> +#endif
> +}
> +
> #endif /* __GNUC__ */
>
> #endif /* AVUTIL_X86_INTMATH_H */
> -- 1.9.5.github.0
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list