[FFmpeg-devel] [PATCH] avutil/intmath: use bzhi gcc builtin in av_mod_uintp2()

James Almer jamrial at gmail.com
Fri Jun 26 23:13:08 CEST 2015


On 26/06/15 4:56 PM, Carl Eugen Hoyos wrote:
> On Friday 26 June 2015 09:52:31 pm James Almer wrote:
> 
>> +#if AV_GCC_VERSION_AT_LEAST(5,1)
>> +#define av_mod_uintp2 __builtin_ia32_bzhi_si
> 
> Since there are compilers != gcc that define GCC 
> (for example icc), this needs a configure check imo.

Does it define __GNUC__ with a value >=5 like I'm checking above? And
if it defines __GNUC__, shouldn't it support the relevant builtins or
defines?

> 
> What is the advantage over the inline version?

The bzhi instruction sets the ZF flag among others, but GCC apparently
doesn't take it into consideration when it's used inside the __asm__()
block, so something like "if (av_mod_uintp2(foo, bar))" will result in
a bzhi instruction followed by a test instruction.
This doesn't happen if you use the builtin.

> 
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 



More information about the ffmpeg-devel mailing list