1 TITLE: Compiler Optimization
3 AUTHOR: Per Liden <per@fukt.hk-r.se>
6 How to optimize the compilation for a certain CPU.
9 To optimize for a specific architecture you can add the -m<cpu>
10 -march=<cpu> options when compiling. If you want to optimize for, say PII,
11 then you could do someting like this:
13 before running ./configure, type:
17 export CFLAGS="-02 -mpentiumpro -march=pentiumpro"
18 export CXXFLAGS="-02 -mpentiumpro -march=pentiumpro"
22 setenv CFLAGS "-02 -mpentiumpro -march=pentiumpro"
23 setenv CXXFLAGS "-02 -mpentiumpro -march=pentiumpro"
25 the -O2 option could be set to something higher than 2, but 2 is a safe
26 choice. If the package in question doesn't have a ./configure script you
27 sometimes (depending on how the Makefile is written) have to edit the
30 Note that when using the -march=<cpu> option, the compiler will make use
31 of architecture specific instructions, and therefor the binary will not
32 run on older architectures, in this case pentium, i486, etc.
34 The -m<cpu> option does not cause the compiler to generate archetecture
35 specific instructions, however, the compiler schedules the code to perform
36 best on the specified cpu.
38 Valid cpu (Intel and compatables) types in gcc 2.95.2 are:
39 486, pentium, pentiumpro, k6