From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,e2617bb212aeb68e X-Google-Attributes: gidfee84,public From: patchkov@acs1.acs.ucalgary.ca (Serguei Patchkovskii) Subject: Re: DecC vs. gcc-2.8.1, why is the difference in speed so large? Date: 1999/06/08 Message-ID: <7jjcs4$kvg@ds2.acs.ucalgary.ca>#1/1 X-Deja-AN: 487101552 References: Organization: The University of Calgary Newsgroups: comp.unix.osf.osf1 Christoph Walti (njmp_walti@njmp_solid.phys.ethz.ch) wrote: : recently, I compared the speed of a very simple program (posted below), : which was once compiled using DecC and a second time using GNU gcc-2.8.1 : on a Digital-alpha staion DS20 with DUnix4.0F. To my very surprise, the : DecC-compiled version was at least 30, if not even 50 times as fast as the : gcc-compiled version! I did not use any optimisation flags, but the ones [snip] : void do_that(int *anz) : { : int i,j,x; : for (i=0; i <15; i++) { : printf("doing this\n"); : x=0; : for (j=0; j <10000000; j++) x=x+i; /* 10 millions */ : (*anz)++; : } : } Your benchmark is meaningless, as the entire inner loop computing 'x' can be eliminated after simple local analysis of the do_that() subroutine. gcc deliberately refrains from performing loop elimination in such cases, as this can result in unexpected results for programs relying on loops for delays (which is a bad idea in any case - but that had never stopped anyone). DEC cc apparently removes your inner loop at the default optimization level, which can easily explain a factor of 50 difference in the timing. /Serge.P -- home page: http://www.cobalt.chem.ucalgary.ca/ps/