[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#291693: gcc-3.3: optimization -O2 is worst than -O1



Package: gcc-3.3
Version: 1:3.3.5-5
Severity: normal

 I found this page
 http://www.network-theory.co.uk/docs/gccintro/gccintro_43.html
 and i diceide to try it becouse i was curios of
 optimizations.
 And the results are little strange. 
 I have two more configuration on woody and one redhat9 
 with default packages installed and updated.
 Here are results:
 Debian Testing:
 Linux version 2.6.8-2-686 (dilinger@toaster.hq.voxel.net) (gcc version
 3.3.5 (Debian 1:3.3.5-5)) #1 Sat Jan 8 16:50:08 EST 200
 5
 carredas:/home/edmon# cat /proc/cpuinfo
 processor       : 0
 vendor_id       : GenuineIntel
 cpu family      : 15
 model           : 2
 model name      : Intel(R) Celeron(R) CPU 2.00GHz
 stepping        : 9
 cpu MHz         : 1991.977
 cache size      : 128 KB
 fdiv_bug        : no
 hlt_bug         : no
 f00f_bug        : no
 coma_bug        : no
 fpu             : yes
 fpu_exception   : yes
 cpuid level     : 2
 wp              : yes
 flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
 mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
 bogomips        : 3948.54
 carredas:/home/edmon# gcc -Wall -O0 test.c -lm
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m8.381s
 user    0m8.374s
 sys     0m0.004s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m8.409s
 user    0m8.360s
 sys     0m0.007s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m8.381s
 user    0m8.378s
 sys     0m0.004s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m8.339s
 user    0m8.333s
 sys     0m0.001s
 carredas:/home/edmon# gcc -Wall -O1 test.c -lm
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.644s
 user    0m5.641s
 sys     0m0.002s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.640s
 user    0m5.638s
 sys     0m0.002s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.647s
 user    0m5.646s
 sys     0m0.001s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.651s
 user    0m5.649s
 sys     0m0.000s
 carredas:/home/edmon# gcc -Wall -O2 test.c -lm
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.726s
 user    0m5.722s
 sys     0m0.002s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.731s
 user    0m5.723s
 sys     0m0.003s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m5.792s
 user    0m5.731s
 sys     0m0.008s
 carredas:/home/edmon# gcc -Wall -O3 test.c -lm
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m4.218s
 user    0m4.215s
 sys     0m0.003s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m4.186s
 user    0m4.182s
 sys     0m0.003s
 carredas:/home/edmon# time ./a.out
 sum = 4e+38

 real    0m4.189s
 user    0m4.187s
 sys     0m0.001s


 Debian Woody:
 Linux version 2.2.19 (herbert@gondolin) (gcc version 2.7.2.3) #1 Sat
 Jun 9 13:04:06 EST 2001
 mail:~# cat /proc/cpuinfo
 processor       : 0
 vendor_id       : GenuineIntel
 cpu family      : 5
 model           : 4
 model name      : Pentium MMX
 stepping        : 3
 cpu MHz         : 171.309
 fdiv_bug        : no
 hlt_bug         : no
 sep_bug         : no
 f00f_bug        : yes
 coma_bug        : no
 fpu             : yes
 fpu_exception   : yes
 cpuid level     : 1
 wp              : yes
 flags           : fpu vme de pse tsc msr mce cx8 mmx
 bogomips        : 341.60
 mail:~# gcc -Wall -O0 test.c -lm
 mail:~# time ./a.out
 sum = 4e+38

 real    1m18.922s
 user    1m13.630s
 sys     0m0.010s
 mail:~# gcc -Wall -O1 test.c -lm
 mail:~# time ./a.out
 sum = 4e+38

 real    0m46.862s
 user    0m45.240s
 sys     0m0.030s
 mail:~# gcc -Wall -O2 test.c -lm
 mail:~# time ./a.out
 sum = 4e+38

 real    0m45.667s
 user    0m44.320s
 sys     0m0.010s
 mail:~# gcc -Wall -O3 test.c -lm
 mail:~# time ./a.out
 sum = 4e+38

 real    0m22.718s
 user    0m21.730s
 sys     0m0.010s

 And REd Hat 9:
 Linux version 2.4.20-8smp (bhcompile@porky.devel.redhat.com) (gcc
 version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 SMP Thu M
 ar 13 17:45:54 EST 2003
 [root@epsilone root]# cat /proc/cpuinfo
 processor       : 0
 vendor_id       : GenuineIntel
 cpu family      : 15
 model           : 2
 model name      : Intel(R) Pentium(R) 4 CPU 2.40GHz
 stepping        : 9
 cpu MHz         : 2411.645
 cache size      : 512 KB
 physical id     : 0
 siblings        : 2
 fdiv_bug        : no
 hlt_bug         : no
 f00f_bug        : no
 coma_bug        : no
 fpu             : yes
 fpu_exception   : yes
 cpuid level     : 2
 wp              : yes
 flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
 mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
 bogomips        : 4810.34

 processor       : 1
 vendor_id       : GenuineIntel
 cpu family      : 15
 model           : 2
 model name      : Intel(R) Pentium(R) 4 CPU 2.40GHz
 stepping        : 9
 cpu MHz         : 2411.645
 cache size      : 512 KB
 physical id     : 0
 siblings        : 2
 fdiv_bug        : no
 hlt_bug         : no
 f00f_bug        : no
 coma_bug        : no
 fpu             : yes
 fpu_exception   : yes
 cpuid level     : 2
 wp              : yes
 flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
 mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
 bogomips        : 4810.34

 [root@epsilone root]# gcc -Wall -O0 test.c -lm
 [root@epsilone root]# time ./a.out
 sum = 4e+38

 real    0m10.779s
 user    0m10.780s
 sys     0m0.000s
 [root@epsilone root]# gcc -Wall -O1 test.c -lm
 [root@epsilone root]# time ./a.out
 sum = 4e+38

 real    0m5.161s
 user    0m5.140s
 sys     0m0.000s
 [root@epsilone root]# gcc -Wall -O2 test.c -lm
 [root@epsilone root]# time ./a.out
 sum = 4e+38

 real    0m5.123s
 user    0m5.110s
 sys     0m0.000s
 [root@epsilone root]# gcc -Wall -O3 test.c -lm
 [root@epsilone root]# time ./a.out
 sum = 4e+38

 real    0m3.245s
 user    0m3.240s
 sys     0m0.000s
 

As you see result for testing for -O2 are worst than -O1 :(

I am not very in compiling and so on .
Maybe i am missing something.
It will be good if bigger optimization gives better results:)))

:)

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-2-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages gcc-3.3 depends on:
ii  binutils                    2.15-5       The GNU assembler, linker and bina
ii  cpp-3.3                     1:3.3.5-5    The GNU C preprocessor
ii  gcc-3.3-base                1:3.3.5-5    The GNU Compiler Collection (base 
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  libgcc1                     1:3.4.3-6    GCC support library

-- no debconf information



Reply to: