Compiler optimization (was Re:linuxcaffe; distros and desktops)

Anton Markov anton-F0u+EriZ6ihBDgjK7y7TUQ at public.gmane.org
Sat Oct 30 23:36:36 UTC 2004


Noah John Gellner wrote:
> I have been wondering about the differences between -O2 and -O3. I
> typically use -O2, but I am starting to experiment about -O3. For a P4
> 2.4 w/ 684M of RAM, should -O3 be faster?

I am no expert on this, but I researched into compiler optimization some 
time ago.

Your best friend is the GCC manpage "man gcc". Do a search (hit "/") for 
-O2; there should be a detailed description burried in the manpage. 
Basically -O2 improves performance at the expense of compilation time. 
-O3 should slightly increase performance but will make the final code 
larger, which may or may not hurt performance in the end (load times, 
RAM/Swap usage, etc.). I personally have never used -O3.

Since you have a P4, you can optimize the code (especially 
graphical/computational programs) by enabling the MMX/SSE/SSE2 math 
instructions and other CPU-specific stuff. Search the gcc manpage for 
"Intel 386 and AMD x86-64 Options" and read the descriptions.

On my P4 2.4GHz I used the following when compiling the X.Org server:
"-O2 -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse"

-- 
Anton Markov <("anton" + "@" + "truxtar" + "." + "com")>

GnuPG Key fingerprint =
5546 A6E2 1FFB 9BB8 15C3  CE34 46B7 8D93 3AD1 44B4

*** LINUX - MAY THE SOURCE BE WITH YOU! ***
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://gtalug.org/pipermail/legacy/attachments/20041030/a47669dc/attachment.sig>


More information about the Legacy mailing list