Why system gcc that is 4.2.1 produces different code than gcc-4.2.1 compiled from sources?
I ran this simple example: #include stdlib.h #include stdio.h int fib(int AnArg) { if (AnArg = 2) return (1); return (fib(AnArg-1)+fib(AnArg-2)); } int main(int argc, char* argv[]) { int n = atoi(argv[1]); printf(fib(%i)=%i\n, n, fib(n)); } through system gcc and gcc built from sources. Both are 4.2.1. Options: -O3. Average runtime with the argument 45 is quite different: system gcc is 3.650s and gcc-4.2.1 from sources is 3.740. CPU: Intel(R) Core(TM) i7 CPU @ 9200 @ 2.67GHz Yuri ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Why system gcc that is 4.2.1 produces different code than gcc-4.2.1 compiled from sources?
Yuri y...@rawbw.com writes: I ran this simple example: #include stdlib.h #include stdio.h int fib(int AnArg) { if (AnArg = 2) return (1); return (fib(AnArg-1)+fib(AnArg-2)); } int main(int argc, char* argv[]) { int n = atoi(argv[1]); printf(fib(%i)=%i\n, n, fib(n)); } through system gcc and gcc built from sources. Both are 4.2.1. Options: -O3. Average runtime with the argument 45 is quite different: system gcc is 3.650s and gcc-4.2.1 from sources is 3.740. CPU: Intel(R) Core(TM) i7 CPU @ 9200 @ 2.67GHz Hi, I'm pretty sure that a small difference in execution time does not mean that the produced code is different. In order to check the code gcc produced, you need to do something like this: objdump -d executable or even use gdb's disassemble command. Regards, Leonidas Yuri ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Why system gcc that is 4.2.1 produces different code than gcc-4.2.1 compiled from sources?
Leonidas Tsampros wrote: I'm pretty sure that a small difference in execution time does not mean that the produced code is different. Actually, execution time of a process is very sensitive to the environment of this process. See for instance: http://www-plan.cs.colorado.edu/diwan/asplos09.pdf We see that something external and orthogonal to the program, i.e., changing the size (in bytes) of an unused environment variable, can dramatically (frequently by about 33% and once by almost 300%) change the performance of our program. (The quotation is taken out of the article.) I learned about this in a message from Xavier Leroy to the OCaml mailing list: http://caml.inria.fr/pub/ml-archives/caml-list/2009/12/e261eeb95bec6c5a2791335c84234a05.en.html Cheers, Michaël ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org