[FFmpeg-devel] Inline ASM vs. Intrinsics

Rich Felker dalias
Fri May 11 04:52:52 CEST 2007

On Fri, May 11, 2007 at 10:09:22AM +0800, Zuxy Meng wrote:
> Hi,
> 2007/5/9, Thorsten Jordan <tjordan at macrosystem.de>:
> > Hello developers,
> >
> > i am wondering what do you think about the MMX/SSE intrinsics that can
> > be used at least with gcc (and maybe also with intels compiler).
> >
> > My question is if they are not used because of performance or if they
> > are a big NoNo because of some other reason.
> >
> > I know that by using inline asm one has most control over what is going
> > on. However with intrinsics the code is sometimes shorter and easier to
> > read, although recent compilers are rather good in code generation. The
> > intrinsics have one big advantage: you can use the very same code f?r
> > x86-32 and x86-64 and on the latter the 8 extra registers are used
> > automatically.
> I agree, and since gcc knows more about what intrinsics do than inline
> assembly, gcc may optimize better with different march/mtune settings.

I'm strongly against intrinsics. If you're writing asm, you have an
exact intention of what machine code you want output. At best the
compiler can duplicate that, and at worst (and in all likelihood, with
gcc's suckage) the compiler will screw it up.

Extending the C language with machine-specific intrinsics is a
disgusting and misguided practice in principle as well. C is for
writing the code that's portable between machines, ASM is for writing
machine-specific optimizations. There's no excuse for polluting C with
machine-specific stuff.


More information about the ffmpeg-devel mailing list