[FFmpeg-devel] [FFmpeg-cvslog] r12171 - trunk/doc/optimization.txt

Reimar Döffinger Reimar.Doeffinger
Thu Feb 21 20:46:58 CET 2008

On Thu, Feb 21, 2008 at 09:16:39PM +0200, ?smail D?nmez wrote:
> If you can give an example based on complex asm we can report a bug to
> gcc, just saying gcc is not a good optimizer
> does not help anyone, do we have another better open source compiler?

I doubt we have any seriously better compiler at all.

> No. So if you have a better example of bad asm produced we can ask
> gcc developers.

Not asm, but maybe someone is motivated to test this with a up-to-date
gcc on some 32 bit system:
> #include <inttypes.h>
> uint64_t a;
> uint16_t b;
> uint64_t mul(void) {
>   return a * b;
> }

gcc -fomit-frame-pointer -O3 -S stupidtest.c -o -
gcc 4.2.3 at least makes the wonderful:
>        pushl   %ebx
>        movzwl  b, %eax
>        xorl    %edx, %edx
>        movl    a, %ebx
>        movl    a+4, %ecx
>        imull   %edx, %ebx
>        imull   %eax, %ecx
>        mull    a
>        addl    %ecx, %ebx
>        addl    %edx, %ebx
>        movl    %ebx, %edx
>        popl    %ebx
>        ret

Not the masterpiece of adding one useless xor, one useless imull (a
human learns very soon in live the result of multiplying by 0), and a
useless add (the result of adding 0 is only slightly less complex).
Note that this does not happen when using uint32_t instead of uint16_t,
so obviously they have added a special-case for that (which of course
will lead to nicely bloated code if they hack a special case for every
architecture and every combination of types (where one is larger than
the native size)...).

Reimar D?ffinger

More information about the ffmpeg-devel mailing list