[FFmpeg-devel] looking for comparison of intrinsics vs hand written asm

Frank Barchard fbarchard
Fri Oct 30 20:44:29 CET 2009


On Fri, Oct 30, 2009 at 8:34 AM, Attila Kinali <attila at kinali.ch> wrote:

> Moin,
>
> I had discussion with some prof about code optimization
> and it came to a point where we disagreed on how big
> the difference between intrinsics and hand written asm
> is. I was quite sure that i've seen somewhere such a comparison,
> done by someone with a clue (ie both intrinsics and asm had
> a good quality), but cannot find anything anymore.
>
> Hence, i'd like to ask if someone has such a comparison.
> If possible also against intrinsics compiled with icc.
>

I did a YUV converter with intrinsics vs asm with Visual C and it was 10%
faster doing the full loop in asm.
asm has 2 advantages
1. more control over order, letting you tune to architecture.  ie you can
pair instructions
2. control over registers.  on x86 its easy to spill registers, and the
choice of registers can make a difference to performance.

It depends largely on the compiler and cpu.  icc does better with register
allocation than gcc or vc.
x86 has more registers and better abi than ia32.
Visual Studio 2010 for x64 doesnt give you a choice to use inline.  Its
either intrinsics, or masm. (or yasm).
inline and intrinsics can cut calling overhead and letting you do smaller
bits of assembly.

Intrinsics are more portable, so its certainly better to do intrinsics than
fall back on C code.
It takes more effort, but I do mostly asm for the extra performance.



More information about the ffmpeg-devel mailing list