[FFmpeg-devel] [PATCH] update doc/optimization.txt

Ronald S. Bultje rsbultje
Thu Sep 23 00:01:26 CEST 2010


Hi Michael,

On Wed, Sep 22, 2010 at 5:50 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> id like to point out that xmm/mmx clobbers are only ok if either
> 1. they are needed for correct functioning of actual binary code
> 2. they cause no speedloss and add no instructions
>
> or to say it the other way around iam against making our code slower
> for language lawyering correctness
>
> this applies to register saving in yasm as well
> so yes i oppose saving xmm registers on win64 if its unneeded
> you can do such saveing & restoring at an outer layer like the slice decode
> function so the clobbering cannot leak but doing it in each optimized function
> is silly if its unneeded. (of course its not silly if it is needed ...)

Understood.

XMM clobbering or the cglobal thing does nothing on Linux or other
Unixy systems where it's not required. It only has some effect on
Win64, where it is needed. On Win64 (at least), XMM registers are
actually used in regular C code (e.g. in ffmpeg.c) when compiled with
a regular compiler such as gcc, and they are callee-save, so not
saving/restoring them has undefined effects. I haven't checked what
they are used for (possibly float storage or so? The "undefined
effect" always effected float code...), so in theory it may be
possible to save/restore them similar to how we handle emms assuming
that our decoders using fxp simd don't use any float code (basically
same assumption as with emms). I'm not really sure about this, I'd
like Loren's input before I change anything. More generally, since
this has no effect on Unixy systems (neither negative nor positive)
I'm not sure if anyone cares...

Yasm never does anything for mmx registers. I don't think marking them
as clobbered in inline asm does anything but I haven't checked this.
The doc specifically excludes mentioning that mmx registers should be
marked as clobbered; they are always caller-save.

Ronald



More information about the ffmpeg-devel mailing list