[Ffmpeg-devel] [PATCH] lowres chroma bug

Trent Piepho xyzzy
Thu Feb 8 00:51:22 CET 2007


On Wed, 7 Feb 2007, Michael Niedermayer wrote:
> > Instead of hardcoding the scratch register, it's better to let gcc choose a
> > register.  Like this:
>
> last time i compared hardcoded registers with gcc-choosen ones, the later
> where slower (that was in cabac.h in case you want to proof me wrong, id
> be happy if we could get rid of the hardcoded registers there ...)

It going to depend a lot on how the code is used.  If your asm will only
appear in one place, ie. it's neither a macro nor an inlined function nor
in a unrolled loop, etc., the you could just let gcc pick a register and
then go back and hardcode that same register.  That should generate the
exact same code.  So assuming you pick a good register, you will do no
worse than gcc.

The advantage comes when the code is a macro or inlined in multiple places.
With a hard coded register, the same register must be used each time.  If
you let gcc choose, it can pick different registers depending on the
context.  In this case, no matter what register you pick, you may do worse
than letting gcc pick.

Like the inlined put_bits() function in bitstream.h, I think you would get
better code if the eax wasn't hardcoded.

Of course, gcc redoes register allocation each time you change the code,
compile with different -fPIC/-fomit-frame-pointer settings, or try a
register calling convention.  It is certainly more work to maintain as good
or better register choices than gcc in those situations where it is even
possible to due so.




More information about the ffmpeg-devel mailing list