Reputation: 611
I am compiling an example program with the following command:
$ gcc -march=i386 -mtune=i386 -mmmx -msse4 -m3dnow -m32 -o hello.exe hello.c
Questions:
Upvotes: 1
Views: 305
Reputation: 20641
Why doesn't GCC complain that the switches for enabling MMX, SSE4 and 3DNow! are incompatible with the chosen architecture i386?
Because the architecture chosen with -march=
specifies, among other things, the instruction set extensions that are available; you then explicitly add MMX, SSE4 and 3DNow! to the set of extensions the compiler will use. If you consider that i386 is the "base" architecture for the following architectures which implemented those instruction set extensions, this makes perfect sense.
Putting it another way: -march=i386
by itself reduces the set of instructions used, including extensions, so that the produced code will run on a 386 processor. Later options (-mmmx
etc) add to the set of instructions used. The combination of -march=i386 -mmmx
doesn't really make sense, but if you specifically ask for that combination, that's what you'll get. It would take extra logic in the the compiler to deduce that the combination is nonsensical.
(-march
also sets various tuning parameters, at least for x86. Unless I'm mistaken, the -mtune=i386
is redundant).
Does the compiler generate an executable that cannot run on i386?
Yes, potentially; this is exactly what you asked it to do with each of -mmmx -msse4 -m3dnow
.
Upvotes: 2