- publishing free software manuals
An Introduction to GCC - for the GNU compilers gcc and g++
by Brian J. Gough, foreword by Richard M. Stallman
Paperback (6"x9"), 144 pages
ISBN 0954161793
RRP £12.95 ($19.95)

"An excellent introduction... fills a much-needed niche in the marketplace" --- Association of C and C++ Users book review (Issue 16-4, August 2004) Get a printed copy>>>

8.1 Intel and AMD x86 options

The features of the widely used Intel and AMD x86 families of processors (386, 486, Pentium, etc) can be controlled with GCC platform-specific options.

On these platforms, GCC produces executable code which is compatible with all the processors in the x86 family by default--going all the way back to the 386. However, it is also possible to compile for a specific processor to obtain better performance.(21)

For example, recent versions of GCC have specific support for newer processors such as the Pentium 4 and AMD Athlon. These can be selected with the following option for the Pentium 4,

$ gcc -Wall -march=pentium4 hello.c

and for the Athlon:

$ gcc -Wall -march=athlon hello.c

A complete list of supported CPU types can be found in the GCC Reference Manual.

Code produced with a specific -march=CPU option will be faster but will not run on other processors in the x86 family. If you plan to distribute executable files for general use on Intel and AMD processors they should be compiled without any -march options.

As an alternative, the -mcpu=CPU option provides a compromise between speed and portability--it generates code that is tuned for a specific processor, in terms of instruction scheduling, but does not use any instructions which are not available on other CPUs in the x86 family.(22) The resulting code will be compatible with all the CPUs, and have a speed advantage on the CPU specified by -mcpu. The executables generated by -mcpu cannot achieve the same performance as -march, but may be more convenient in practice.

ISBN 0954161793An Introduction to GCC - for the GNU compilers gcc and g++See the print edition