Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  • Print
  • + Share This

Architecture-Specific Options

In addition to the optimization options discussed in the previous section, GCC can generate code specific to each CPU type. To do so, use the -m{value} option. Table 3.6 shows a number of the supported options for the Intel i386 processor family.

Table 3.6 Architecture-Specific GCC Options

Option

Meaning

-mcpu=CPU TYPE

Uses the default CPU instruction schedule for CPU_TYPE when compiling. The choices for CPU TYPE are i386, i486, i586, pentium, i686, and pentiumpro.

-m386

Synonym for -mcpu=i386.

-m486

Synonym for -mcpu=i486.

-mpentium

Synonym for -mcpu=pentium.

-mpentiumpro

Synonym for -mcpu=pentiumpro.

-march=CPU TYPE

Generates instructions for CPU TYPE. The choices for CPU TYPE are i386, i486, pentium, and pentiumpro. -march=CPU TYPE implies -mcpu=CPU TYPE.

-mieee-fp

Uses IEEE standards for floating-point comparisons.

-mno-ieee-fp

Doesn't use IEEE standards for floating-point comparisons.

-malign-double

Aligns double, long double, and long long variables on a two word boundary, resulting in faster code.

-mno-align-double

Doesn't align double, long double, and long long variables on a two word boundary.

-mrtd

Forces functions that take a fixed number of arguments to return with the ret NUM instruction, saving one instruction in the caller.


A few notes on these options are necessary. Using a specific CPU TYPE with -mcpu=CPU_TYPE generates appropriate instructions for the indicated CPU. However, you must also use -march=CPU_TYPE or the compiler will generate code that also runs on i386 CPUs. Similarly, to generate code and instruction scheduling specific to a given processor, use the -march=CPU_TYPE option. This is the best way to customize compiled code for a given processor. The -malign_double option results in slightly faster code, as noted in Table 3.6, but it only works for Pentium CPUs. The -mrtd option overrides the -fdefer-stack-pops discussed earlier.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.