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]
Other format: [Raw text]

Performance issues


There is following program:

----------------
struct str{
   int f0;
   int f1;
   int f2;
};

main () {
   double d;
   double* pd=&d;
   str s;
   int* pf=&s.f0;
   s.f0=s.f1=s.f2=0;
   for (int i=0;i<1000000000;++i) {
#ifdef SLOW
      pd[s.f0+s.f1*s.f2]=1;
#else
      pd[pf[0]+pf[1]*pf[2]]=1;
#endif
   }
}
-------------------------------------------
after compilation with gcc-3.2 -O9 on Linux Mandrake 9.0 Athlon 900MHz,

time ./a.out of the SLOW version gives 10.40s
time ./a.out of the "!defined(SLOW)" version gives 3.50s

Logically this is almost the same... Can anyone give me insights what is going on and some advice
how to accelerate SLOW version?

Ilya



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


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