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

Re: For after egcs-2.0, when everything works and we get bored


On Fri, Jul 31, 1998 at 12:17:04PM +0200, Toon Moene wrote:
> So, the 64K question is:  How do we transform the loop nest into  
> the single loop *in the optimisation passes* [and not in the Fortran  
> source code].  I will not deal with this question in its entirety,  
> because I do not know all steps necessary, but I will outline the  
> checks that are necessary on such a loop nest to be able to tell  
> whether it *can* be done.

I think this pretty much has to be done in a higher-level intermediate
language than our current RTL.  Anything else has too much hair.

>       jc = m				! Outer loop count
>       j  = 1				! Outer loop induction var j

Incidentally, why does the fortran front end generate loops in this
way?  Was the loop inversion code not working for you once upon a time?

Seems to me you should just emit

	top = m
	j = 1
	if (j <= top) {
	  do {
	    ...
	  } while (++j <= top);
	}

In this way, you only have one variable to increment around the loop,
and the possibility that j may be replaced by a giv.  As it is, jc
can never be eliminated.

BTW, something that I may be able to give you without too much hair
is reducing

	for (j = 0; j < m; ++j)
	  for (i = 0; i < n; ++i)
	    c[j][i] = a[j][i] + b[j][i];

to 

	/* This is what we get now.  */
	a0 = a; b0 = b; c0 = c;
	for (j = 0; j < m; ++j)
	  {
	    a1 = a0; b1 = b0; c1 = c0;
	    for (i = 0; i < n; ++i)
	      *c1++ = *a1++ + *b1++;
	    a0 += N;
	    b0 += N;
	    c0 += N;
	  }

to 

	a0 = a; b0 = b; c0 = c;
	for (j = 0; j < m; ++j)
	  {
	    for (i = 0; i < n; ++i)
	      *c0++ = *a0++ + *b0++;
	  }

when N (dimension of a[j]) is equal to n.  I don't think I can get
rid of the inner loop at this time:

	a0 = a; b0 = b; c0 = c;
	ce = c0 + m*N;
	if (c0 < ce) 
	  do
	    {
	      *c0++ = *a0++ + *b0++;
	    }
	  while (c0 < ce);

It does look nice though...


r~


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