No optimization works on Alpha?

Oskar Enoksson osken393@student.liu.se
Thu Oct 1 16:51:00 GMT 1998


Thank you, you were right! The performance is now excellent (90% of
native OSF4.0 fortran compiler, not bad!)

Many people do "write fortran in C" though, more specifically everybody
who wants to use some efficient arrayclass in C++ for scientific
calculations.

It would be convenient if the compiler could do this IMHO, but of cource
the arrayclass designer can solve it by using macros to define different
integer types for indexing on different architectures.

Anyway, thanks a lot for your help!

(I'm forwarding this to the egcs list also in case somebody who
doesn't read the bug-list will decide it worth to find out a way
to implement this)

Toon Moene wrote:

> Oskar Enoksson wrote:
> 
> > The common integer subexpressions above do not seem to get
> > elimintated, nor are they moved outside the loop as can be seen from
> > the assembler

> Well, let's call it "shortcoming"; the code doesn't generate wrong  
> results.

Agreed.

> anyway): changing the line
>
>   int i,j,k;
> 
> into
>
>   long i,j,k;
> 
> will make this code perform as fast as the Fortran one.  The reason  
> is that the Fortran front-end will do this transformation itself  
> (courtesy of some hard work by Richard Henderson).  Nobody ever  
> bothered to do the same for the C(++) frontend, apparently because  
> noone believed that people would try to write Fortran in C ;-)

Ok. The original code was:

> > /* Begin foo.cc */
> >
> > #define Op(a,i,j,k) a[(k*50+j)*50+i]
> >
> > main() {
> >   float a[50*50*50];
> >   int i,j,k;
> > 
> >   for(k=0; k<50; k++)
> >     for(j=0; j<50; j++)
> >       for(i=0; i<50; i++)
> >         Op(a,i,j,k)=Op(a,i,j,k)*Op(a,i,j,k);
> > }
> >
> > /* end foo.cc */





More information about the Gcc mailing list