[gcc] Unterschied -mtune und -march
-
Hiho!
Ich verwende ein 32-Bit Linux auf einem Turion64. Aus Spass hab ich grad ein Programm mitgcc -march=k8
kompiliert. Laut Dokumentation ( http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/i386-and-x86_002d64-Options.html ):
-mtune=cpu-type Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions. The choices for cpu-type are: k8, opteron, athlon64, athlon-fx AMD K8 core based CPUs with x86-64 instruction set support. (This supersets MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.) -march=cpu-type Generate instructions for the machine type cpu-type. The choices for cpu-type are the same as for -mtune. Moreover, specifying -march=cpu-type implies -mtune=cpu-type.
Wenn ich das jetzt richtig verstehe, optimiert -mtune einfach fuer eine Rechnerarchitektur, laesst aber die ABI unangetastet, waehrend -march auch die ABI veraendert. Deshalb dachte ich ja eigentlich -march=k8 wuerde mir 64-Bit Binaries erstellen. Das kompilierte Programm laeuft aber problemlos auf meinem (32-Bit) OS. Was hab ich falsch verstanden?
EDIT: Probleme mit dem Quote-Tag
-
die ABI verändert sich durch -march nicht (dafür sind m32/-m64 ; -mregparam, msseregparam,mcmodel etc. da)
-march macht alle instruktionen des gewählten prozessors verfügbar und optimiert für diesen
-mtune benutzt den instruktionssatz des defaults (bzw. dessen, was mit march gewählt wird oder anderweitig aktiviert wird - per mmmx msse usw.), optimiert allerdings den code für den in mtune gewählten prozessor