Use gcc --target-help
-march=CPU[,+EXTENSION...]
generate code for CPU and EXTENSION, CPU is one of:
generic32, generic64, i386, i486, i586, i686,
pentium, pentiumpro, pentiumii, pentiumiii, pentium4,
prescott, nocona, core, core2, corei7, l1om, k1om,
iamcu, k6, k6_2, athlon, opteron, k8, amdfam10,
bdver1, bdver2, bdver3, bdver4, znver1, znver2,
btver1, btver2
...
它通常不是一般的架构x86
or x86-64
但具体的微架构。但有x86-64
(not x86_64
)适用于具有 64 位扩展的通用 x86 CPU。每个架构的完整列表可以在GCC's -march manual https://gcc.gnu.org/onlinedocs/gcc/Option-Index.html#Option-Index_op_letter-M。对于 x86:
...
https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-march-13 https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-march-13
虽然基线版本-march
is -march=x86-64
,基线/默认调整选项是-mtune=generic
。这样做的目的是在任何地方都不会太糟糕,即使以额外的指令或代码大小为代价,也能避免性能缺陷。
-march=native
将为运行编译器的机器选择正确的架构并调整设置,或者tune=generic
如果编译器无法识别正在运行的 CPU 的特定型号。
(例如 Skylake 上的旧 gcc,仍将启用-mavx2 -mpopcnt -mbmi2
等等,但会设置-mtune=generic
而不是更接近合适的东西。)