Portál AbcLinuxu, 12. května 2025 12:28
gcc -O -mcpu=i486 -march=i386 -O2 -march=pentium4 test.c
V manuálových stránkách jsem se dočetl, že u optimalizačních parametrů se použije poslední uvedený, v tomto případě O2. Jak je to ale u voleb pro architekturu a procesor ? Předem díky
$ gcc --version gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) ... $ cat test.c #include <math.h> #include <stdlib.h> int main(void) { int x; double d; d = rand()/RAND_MAX; x = (int)sqrt(cos(log(d))); return x; } $ for cpu in i386 i486 pentium4; do gcc -S -O2 -march=$cpu -o test.march-$cpu.s test.c gcc -S -O2 -mcpu=$cpu -o test.mcpu-$cpu.s test.c done $ gcc -S -O2 -march=i386 -march=i486 -march=pentium4 -o test.march-mix.s test.c $ gcc -S -O2 -mcpu=i386 -mcpu=i486 -mcpu=pentium4 -o test.mcpu-mix.s test.c $ md5sum test.*.s 8faf51760c74234173dea2758e00db55 test.march-i386.s 41bac99687b35b58398026f681b1b8ef test.march-i486.s a1fedd683dad3792010dbc46c61a78d7 test.march-mix.s a1fedd683dad3792010dbc46c61a78d7 test.march-pentium4.s 8faf51760c74234173dea2758e00db55 test.mcpu-i386.s 41bac99687b35b58398026f681b1b8ef test.mcpu-i486.s cac87ac4f17e79d1d43c204e8a817f96 test.mcpu-mix.s cac87ac4f17e79d1d43c204e8a817f96 test.mcpu-pentium4.sTakže se asi vždycky použije poslední -O, -mcpu a -march.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.