No optimization works on Alpha?
Toon Moene
toon@moene.indiv.nluug.nl
Wed Sep 30 13:45:00 GMT 1998
> Now I'm beginning to suspect that there are other
> important non-working optimization features. The following
> code is painfully slow on my OSF4.0 ev56 Alpha using
> egcs-980921:
[ Pseudo rank-3 code in C(++) elided ... ]
> 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 further down. (At least,
> this is what I think, but I must admit I don't know enough
> Alpha assembler to actually understand what the compiler
> is up to)
> Three things make me think it's a bug in egcs:
Well, let's call it "shortcoming"; the code doesn't generate wrong
results.
> * The assembler inner loop is MUCH shorter on my Alpha
> using OSF4.0 cxx. * The assembler inner loop is MUCH
> shorter on my Alpha using egcs g77 and corresponding
> fortran code. * The assembler inner loop is MUCH shorter
> on my pentium with egcs 1.1.
Excellent analysis. I'll make a prediction (that's my job,
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 ;-)
Rank-1 arrays in C(++) shouldn't exhibit this problem.
For a discussion of Richard's g77 solution (actually in f/com.c),
see a mail with subject "Re: More than you ever wanted to know about
Fortran array indexing ;-)" from his hand to the egcs list on the
5th of October last year in the archives.
Cheers,
Toon.
More information about the Gcc-bugs
mailing list