With -ax{i|M|K|W} you can instruct the compiler to compile your application so that processor-specific extensions are included in the compilation but only used if the processor supports them as follows:
i
Pentium
Pro, Pentium II processors
M Pentium
with MMX technology processor
K Pentium
III processor
W Pentium
4 and Xeon processors
When the compiled application is run, it detects the extensions supported by the processor.
If the processor supports the specialized extensions, the extensions are executed.
If the processor does not support the specialized code, the extensions are not executed and a more generic version of the code is executed instead.
Applications compiled with -ax{i|M|K|W} have increased code size, but the performance of such code is better than standard optimized code, although slightly slower than if compiled with the -x{i|M|K|W} due to the latter's smaller overhead of checking for which processor the application is being run on.
Note
Applications that you compile to optimize themselves for specific processors
in this way will execute on any Intel 32-bit processor. Such compilations
are, however subject to any exclusive specialized code restrictions you
impose during compilation with the -x option.
To Optimize for... |
Use this option |
PentiumŪ Pro and Pentium II processors, which use the CMOV and FCMOV, and FCOMI instructions |
-axi |
Pentium processors with MMX(TM) technology instructions |
-axM |
Pentium III processor with the Streaming SIMD Extensions, implies i and M instructions |
-axK |
Pentium 4 processor with the Streaming SIMD Extensions 2, implies i, M, and K instructions |
-axW |
The -ax{i|M|K|W} option directs the compiler to find opportunities to generate special versions of functions that use instructions supported on the specified processors. If the compiler finds such an opportunity, it first checks whether generating a processor-specific version of a function results in a performance gain. If this is the case, the compiler generates both a processor-specific version of a function and a generic version of this function that will run on any IA-32 architecture processor.
You can specify more than one code with the -ax option. For example, if you specify -axMK, the compiler will decide whether the resulting executable will benefit better from the MMX technology (M) or the Streaming SIMD Extensions (K). At runtime, one of the two versions is chosen to execute depending on the processor the program is currently running on. In this way, the program can get large performance gains on more advanced processors, while still working properly on older processors. It is the developer's responsibility to use the option's version corresponding to the processor generation.
The disadvantages of using -ax{i|M|K|W} are:
The size of the binary increases because it contains processor-specific and generic versions of the code.
The runtime checks to determine which code to run slightly affect performance.