gcc march and x86 instruction flags

seeker010

New member
These switches enable or disable the use of instructions in the MMX, SSE, SSE2 or 3DNow! extended instruction sets. These extensions are also available as built-in functions: see X86 Built-in Functions, for details of the functions enabled and disabled by these switches.

To have SSE/SSE2 instructions generated automatically from floating-point code (as opposed to 387 instructions), see -mfpmath=sse.

These options will enable GCC to use these extended instructions in generated code, even without -mfpmath=sse. Applications which perform runtime CPU detection must compile separate files for each supported architecture, using the appropriate flags. In particular, the file containing the CPU detection code should be compiled without these options.
so according to the gcc docs, using arch flags and the implied instruction flags allows gcc to generate code using the complete ISA for that architecture. For example, -march=k6-2 implies -m3dnow and -mmmx, which means the assembly code should contain both 3dnow and mmx instructions, but I have yet to see a case of that happening unless I specifically use the builtin datatypes and functions.
 
Last edited:
well I tried to do it myself with inline functions. only the compiler decided this was rather efficient:

Code:
movd %mm0,%eax
movd %eax,%mm0
 
Back
Top