gcc -march=native produces code that is optimized for the CPU that is used to compile the program.
Code produced with -march=native is not backwards compatible, for example, an executable procuded on an Intel Core CPU won't be able to run on an (old) Intel Atom CPU.)
Other possible values for the x86 family are:
x86-64
i386
i486
i586 or pentium
lakemont
pentium-mmx
pentiumpro
i686
pentium2
pentium3 or pentium-m
pentium4 or pentium4m
…
prog.c
#include <stdio.h>
int main() {
int fac_10 =1*2*3*4*5*6*7*8*9*10;
printf("10! = %d\n", fac_10);
return 0;
}
For example, to select the second level, x86-64-v3, a programmer would build a shared object with the -march=x86-64-v3 GCC flag. The resulting shared object needs to be installed into the directory /usr/lib64/glibc-hwcaps/x86-64-v3 or /usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3 (in case of dis- tributions with a multi-arch file system layout). In order to support systems that only implement the K8 baseline, a fallback implementation must be installed into the default locations, /usr/lib64 or /usr/lib/x86_64-linux-gnu. It has to be built with -march=x86-64 (the upstream GCC default). If this guideline is not followed, loading the library will fail on systems that do not support the level for which the optimized shared object was built.
-mwindows
Apparently, there is also the possibility to set arch to windows: -mwindows.