[MPlayer-dev-eng] dsputil_mmx.c: -O2

Corey Hickey bugfood-ml at fatooh.org
Mon Sep 18 23:08:46 CEST 2006


Michael Niedermayer wrote:
> Hi
> 
> On Sun, Sep 17, 2006 at 10:18:39PM -0700, Corey Hickey wrote:
> [...]
>> ------------------------------------------------------------------------------
>> gcc-4.1 (GCC) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)
>>
>> ---  -O4   ---
>> user    3m20.476s
>> user    3m21.011s
>> user    3m24.656s
>>
>> ---  -Os   ---
>> user    3m3.894s
>> user    3m4.803s
>> user    3m3.673s
>>
>> ---  -O2   ---
>> user    2m57.453s
>> user    2m57.820s
>> user    2m58.419s
> 
> the docs say:
> `-O3'
>      Optimize yet more.  `-O3' turns on all optimizations specified by
>      `-O2' and also turns on the `-finline-functions',
>      `-funswitch-loops' and `-fgcse-after-reload' options.

For gcc 4.1, the manual says instead:
     Optimize yet more.  -O3 turns on all optimizations specified by -O2
     and also turns on the -finline-functions and -frename-registers
     options.

Just to be sure, I checked -funswitch-loops and -fgcse-after-reload. 
They have no effect (md5sum libavcodec/i386/dsputil_mmx.o is the same).

> could you test these switches individually?

Sure. These are all with gcc 4.1. MPlayer was compiled entirely with 
-O2; the following pertain specifically to libavcodec/i386/dsputil_mmx.c

---   -O2   ---
user    2m57.765s
user    2m58.062s
user    2m57.593s

---   -O2 -finline-functions   ---
user    3m8.933s
user    3m8.613s
user    3m9.179s

---   -O2 -frename-registers   ---
user    2m57.531s
user    2m58.053s
user    2m58.009s

---   -O2 -finline-functions -frename-registers   ---
user    3m9.133s
user    3m8.555s
user    3m9.098s

---   -O3   ---
user    3m18.375s
user    3m18.321s
user    3m18.540s


I don't know why -O3 is different from "-O2 -finline-functions 
-frename-registers". Either something is misdocumented or a PEBKAC on my 
part. I checked the md5sums of dsputil_mmx.o and they were indeed different.


I wasn't able to see what is going on in the gcc source, but this is my 
first time looking at it and I didn't spend much time. In gcc 4.1.1, we 
have:

gcc/opts.c:587
   if (optimize >= 3)
     {
       flag_inline_functions = 1;
       flag_unswitch_loops = 1;
       flag_gcse_after_reload = 1;
     }

As I mentioned before, -funswitch-loops and -fgcse-after-reload have no 
effect. I even tried "-O2 -finline-functions -frename-registers 
-funswitch-loops -fgcse-after-reload", but there was no difference.

Conversely, "-O3" is the same as "-O3 -fno-unswitch-loops 
-fno-gcse-after-reload".

> and whats the output with -Winline from both -O2 and -O4?

No output with either of them. Here's the full command, if it's of any use:

gcc-4.1 -DHAVE_AV_CONFIG_H -I.. -I../libavutil 
-Wdeclaration-after-statement -O2 -march=k8 -mtune=k8 -pipe -ffast-math 
-fomit-frame-pointer -D_REENTRANT -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I/usr/include/directfb 
-I/usr/include  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT 
-I/usr/include/kde/artsc -pthread -I/usr/include/glib-2.0 
-I/usr/lib/glib-2.0/include  -I/usr/include -I/usr/include/dvdnav 
-I/usr/include/freetype2 -I/usr/local/lib/live/liveMedia/include 
       -I/usr/local/lib/live/UsageEnvironment/include 
-I/usr/local/lib/live/BasicUsageEnvironment/include 
-I/usr/local/lib/live/groupsock/include -D_FILE_OFFSET_BITS=64 
-D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE   -Winline -O3  -c -o 
i386/dsputil_mmx.o i386/dsputil_mmx.c

-Corey



More information about the MPlayer-dev-eng mailing list