This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
has the linker an impact on performance of generated code?
- To: egcs at cygnus dot com
- Subject: has the linker an impact on performance of generated code?
- From: Paolo Losi <losi at altrimedia dot it>
- Date: Mon, 28 Sep 1998 23:55:31 +0000
Hello,
the question is simple: is that possible that in between all the
possible combinations of compilers (egcs 1.1b gcc 2.7.2.3) switches (-O1
-O2 -O3) and linkers the best solution as far as performance of
generated code is concerned is the following:
egcs -c -O1 -fomit-frame-pointer prime.c
gcc-2.7 -s -lm prime.o
In particular the performance is 10% better that that obtained using
egcs's linker:
egcs -c -O1 -fomit-frame-pointer prime.c
egcs -s -lm prime.o
How could you explain that?
Thanks
Paolo Losi
P.S. please CC: the answer to me directly
the system is:
P166MMX linux 2.0.35
ld.so 1.9.9
libc 5.4.46
prime.c:
#include "math.h"
#include "stdio.h"
int main(int argc,char **argv) {
long long num;
long long i,max;
int prime;
sscanf(argv[1],"%lld",&num);
printf("%lld\n",num);
while (num % 2 == 0) {
printf("2 ");
num >>= 1;
}
while(num != 1) {
prime=1;
max=(long long) sqrt((double) num);
if(3>max) max=3;
for(i=3;i<=max;i+=2)
if(num%i==0) {
num /= i;
prime=0;
printf("%lld ",i);
break;
}
if(prime==1) {
printf("%lld \n",num);
num=1;
}
}
return 0;
}