Global variables are slower?

N8TM@aol.com N8TM@aol.com
Fri Feb 11 15:13:00 GMT 2000


 >The program is (yes, I should have used volatile, but I am sure that gcc
 >cannot optimize this case to the extent a human can):
 >
 >#include <stdio.h>
 >
 >int i; int main() { int a,j; a=0;
 >for(j=0;j<1000;j++) for(i=0;i<1000000;i++)  a+=i;

gnu compilers don't emphasize optimization of things like this which matter only in poorly written benchmarks; they concentrate more on useful things.  Not that many compilers would find the value of a which you should know from high school algebra.  Definitely a case where a human could optimize better than any compiler, but many compilers will do more than gcc.

Tim
tprince@computer.org


More information about the Gcc mailing list