This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Global variables are slower?


 >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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]