march= question

Good Evening All.

When building for a particular known arch (bdver2 for example)…What is the difference (if any) of “march=native” vs “march=bdver2”?

I ask, because my peers on the FreeBSD forums were unable to answer.

Sincerely and respectfully,


By using march=native,e you leave it to the compiler’s intelligence to figure out the underlying arch.

The compiler tries to identify the underlying arch using the cpuid flags. Compiler then tries to generate best code for that arch.

By using march=, the user takes the responsibility of advising the compiler to generate best code for the arch that he has selected.

For example,

· Bdver1 architecture has fma4 support.

· Bdver2 architecture has fma3 and fma4 support.

If you use march=bdver1 on a bdver2 machine, compiler generates code which doesn’t have fma3.

If you use march=native on bdver2 machine, the compiler may generate both fma3 and fma4 code.