This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa]: Loop normalization pass
- From: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: gcc-patches at gcc dot gnu dot org, dnovillo at redhat dot com
- Date: 14 Jan 2003 22:23:30 +0100
- Subject: Re: [tree-ssa]: Loop normalization pass
- References: <5B1E4C44-27DE-11D7-869B-000393575BCC@dberlin.org>
Op di 14-01-2003, om 17:36 schreef Daniel Berlin:
>
> On Tuesday, January 14, 2003, at 11:12 AM, Steven Bosscher wrote:
>
> > Daniel Berlin wrote:
> >> Normalizes loops to start at 1 (or would we rather 0), and have
> >> a stride of 1.
> >>
> > ---- 8< ----
> >>
> >> Since it wants loops to start at 1, rather than 0, it normalizes
> >> a *ton* of loops, and thus, is pretty well tested in that respect.
> >
> > If you are suggesting that most loops are only "normalized" because
> > their index starts at 0, then wouldn't it be better indeed to have
> > normalized loops start at 0 too?
>
> Sure. I honestly don't care.
> All the fortran loop optimizers i have source to normalize to 1
Because the first element in a Fortran array has index 1.
> All the C loop optimizers I have source to normalize to 0.
Because the first element in a Fortran array has index 0.
> I assume this is because these are the common lower bounds for these
> languages.
> So I was at a loss which to choose, since we have both, and I presumed
> fortran95 is written by fortran programmers, and thus, they probably
> start their loops at 1 as well.
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.
Greetz
Steven