Question


I need to compile a program targeting a specific architecture or better yet, compile using generic AMD64 instructions ignoring the more recent AMD cpu's (bulldozer and piledriver).

To be specific i need to absolutely ignore any FMA or XOP instructions (my understanding is that these are usually enabled during O2/3 optimizations.

I know that I can specify a specific cpu using --march or -mcpu, but where do I find these values, any ideas?

Thanks!

Was it helpful?

Solution 2

The gcc manual gives:

-mfma4
-mno-fma4
-mxop
-mno-xop

Obviously, depending on the age of your compiler, these may not be supported (but then the compiler won't generate the instructions either)

It is possible to achieve the same thing with -march or similar, but that is much coarser, and will probably turn of a bunch of other extensions/options.

OTHER TIPS

There is options for disabling and enabling specific instruction sets. They may be different in different gcc versions. My gcc 4.7 has following options to enable/disable FMA4 and XOP instruction sets:

-mfma4
-mno-fma4
-mxop
-mno-xop

as I know FMA3 was released after FMA4, and I think my version of gcc does not know about this instruction set.

Also gcc manual says:

While picking a specific cpu-type will schedule things appropriately for that particular chip, the compiler will not generate any code that does not run on the i386 without the -march=cpu-type option being used.

I think this means that if you don't specify -march option your code will run on your architecture correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top