What are my available march/mtune options?

Using gcc --target-help seems like it might be the right idea, but gives an incomplete list.

One workaround on modern gcc versions is just to pass a bogus value to -march:

$ gcc --target-help -march=foo
cc1: error: bad value (‘foo’) for ‘-march=’ switch
cc1: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server bonnell atom silvermont slm knl knm x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 btver1 btver2 native
...

Note how there are many more options compared to the output from --target-help.


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
...

It's often not the general architecture like x86 or x86-64 but the specific microarchitectures. But there's x86-64 (not x86_64) for a generic x86 CPU with 64-bit extensions. The full list for each architecture can be found on GCC's -march manual. For x86:

  • -march=cpu-type

    Generate instructions for the machine type cpu-type. In contrast to -mtune=cpu-type, which merely tunes the generated code for the specified cpu-type, -march=cpu-type allows GCC to generate code that may not run at all on processors other than the one indicated. Specifying -march=cpu-type implies -mtune=cpu-type.

...

https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-march-13


While the baseline version of -march is -march=x86-64, the baseline / default tune option is -mtune=generic. That aims to not be terrible anywhere, avoiding performance pitfalls even at the cost of extra instructions or code size.


-march=native will pick the right arch and tune settings for the machine the compiler is running on, or tune=generic if the compiler doesn't recognize the specific model of CPU it's running on.

(e.g. old gcc on a Skylake, will still enable -mavx2 -mpopcnt -mbmi2 and so on, but will set -mtune=generic instead of something closer to appropriate.)