This is the mail archive of the gcc-patches@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]

Re: [tree-ssa]: Loop normalization pass


Op di 14-01-2003, om 22:34 schreef Daniel Berlin:
> > But the offset of the first element from the array base is still 0, of
> > course.  So actually the Fortran compiler has to change all those
> > indices to (index - 1), e.g.,
> >
> > INTEGER i, A(10), B(10)
> > DO, i=1:10
> >    A(i) = B(i)
> > END DO
> >
> > will eventually be transformed to:
> >
> > integer a[10], b[10];
> > for (int i = 1; i<=10; i++)
> >   a[i - 1] = b[i - 1];
> >
> > or actually the equivalen while(1) form of this.  See what happens if
> > you normalize this loop to 0?
> >
> > Therefore my guess is that normalizing to 0 is the best choice.
> >
> 
> This was my thought, but it made me wonder why then, do  the fortran 
> loop optimizers normalize to 1 (even the non source-source 
> translators), if they have to change it later on  anyway.
> Any idea? Or is it just silliness/oversight on their part?

Well, if I had the opportunity to write loop optimizations on a
Fortranish AST where my array indices start at 1, I would normalize
loops to 1 for consistency during lowering.

At a lower level where all arrays are lowered to some extend, too, that
normalization would not make sense to me.  But if that is what everybody
else is doing, maybe we should try in G95 :-)

I guess that if you read about those optimizers in papers, they'll stay
as close as they can to the language they're optimizing just for
clarity, to better show what the optimization does. If that is not it, I
don't have a clue.

Either way, for GIMPLE, with arrays starting at 0, normalizing to 1
seems silly.

Greetz
Steven



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