### 9.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.27

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.28 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.

#### Footnotes

##### (27)

Also referred to as “targeting” a specific processor.

##### (28)

In recent versions of GCC this option has been renamed to `-mtune`. The older form `-mcpu` will continue to work.