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]

a question about -O5



     Hello,

     I have been comparing SunCC4.2 and egcs-1.1.2
  and stumbled upon interesting thing with optimizers.
  The following two programs are being tried on a Sun Ultra-10
  running at 300 MHz.

--Program 1-----------------------------------------------------
#include <iostream.h>
#include <time.h>
#include <math.h>

int main()
{
   clock();
   unsigned k,j;
   double p,q;
   for (k=0; k<100000; k++)
   for (j=0; j<200; j++)
   {
       p=sqrt(k*j);
       q=p+k; 
   }
   clock_t time=clock();
   cout << "Ticks " << time << endl;
 
}

--Program 2-----------------------------------------------------
#include <iostream.h>
#include <time.h>

int main()
{
   clock();
   unsigned k,j;
   unsigned p,q;
   for (k=0; k<100000; k++)
   for (j=0; j<200; j++)
   {
       p=k*j;
       q=p+k; 
   }
   clock_t time=clock();
   cout << "Ticks " << time << endl;
 
}
---------------------------------------------------------------

   I get the following results

                                 egcs-1.1.2    CC4.2

Prog 1  no optimization            8350K       9570K
Prog 2  no optimization            3700K       3890K
Prog 1  -O5                        2560K       4210K
Prog 2  -O5                          70K         30K

    I understand why Prog 2 -O5 is so far ahead (cause 
    it has no sqrt call and the loop contents can be optimized out),
    but I don't understand why this is the only test where CC wins..


    Is this something that going to be improved?
    I am asking because I am considering moving back to g++ from CC4.2,
    and, of course, -O5 is the most important regime here. Also, I will 
    be seeing CC5.0 in a few weeks max.
 
    Are there any standard compiler comparison suites? 
    Are there known comparisons?

  thanks,
                                                                Igor

   P.S. Please cc: imarkov@cs.ucla.edu as I may not be getting 
        the stuff from the mailing list for a while.



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