← Return to PHP Web Museum

/dev/null

a forum for people who would rather be compiling something

You are not logged in.

#1 2006-01-13 19:30:44

kbuild
New member
From: Munich
Registered: 2005-04-03
Posts: 6

best compiler flags for -O2 vs -O3

Rebuilding a few things with GCC 4.0.2 on an Athlon 64. Is there any point in -O3 for general stuff, or is -O2 -march=athlon64 -pipe where everyone ends up? The Gentoo forums are full of people swearing by flags they never measured.

Offline

 

#2 2006-01-13 20:05:10

horic
Moderator
From: Brno
Registered: 2004-11-02
Posts: 9
Website

Re: best compiler flags for -O2 vs -O3

-O3 mostly adds more aggressive inlining and -funswitch-loops, so binaries get bigger, and on a lot of code they get slower because of cache pressure. Use -O2 unless you have a benchmark that says otherwise.


Debian sarge / 2.6.12 / fluxbox

Online

 

#3 2006-01-13 20:41:29

segv
New member
Registered: 2005-01-18
Posts: 7

Re: best compiler flags for -O2 vs -O3

And -ffast-math is not a free speedup, whatever people say. It drops IEEE semantics and I've watched it break a physics sim in very creative ways.


Segmentation fault (core dumped)

Online

 

#4 Yesterday 11:17:58

kbuild
New member
From: Munich
Registered: 2005-04-03
Posts: 6

Re: best compiler flags for -O2 vs -O3

Quick test with lame, same WAV, best of five runs:

Code:

-O2 -march=athlon64                 41.8s
-O3 -march=athlon64                 41.2s
-O3 -march=athlon64 -funroll-loops  42.0s

Within noise. -O2 it is.

Offline

 

#5 Yesterday 15:47:21

horic
Moderator
From: Brno
Registered: 2004-11-02
Posts: 9
Website

Re: best compiler flags for -O2 vs -O3

Matches what most people find. The one place I've seen -O3 matter is tight numeric loops, and there you should be profiling anyway.


Debian sarge / 2.6.12 / fluxbox

Online

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson