regrename.c rewrite

Richard Henderson
Sat Oct 28 15:04:00 GMT 2000

On Sat, Oct 28, 2000 at 10:05:56PM +0200, Toon Moene wrote:
> However, the sched2 pass still doesn't re-schedule the instructions
> after they got the new (independent) registers assigned.

I've poked at this a bit more.  The problem is nothing to
do with the register renamer.  The problem is with alias
analysis -- we've lost track of the fact that the array
references don't alias.

This happened because the Fortran front end relies on 
being able to track the memory references back to arguments,
and then knowing that no arguments overlap.  Except in this
case we generated code like

	mov	$16, $7
	lda	$16, 4($7)

Why, I'm not exactly sure.  But the effect is that the
argument register gets clobbered, so it is no longer 
considered an argument register.  At which point all of
the memory references alias one another.

Consider the following C rewrite:

	sum(float * __restrict a,
	    float * __restrict b,
	    float * __restrict c, long n)
	  long i, N;
	  for (i = 0, N = n; N > 0; ++i, --N)
	    c[i] = a[i] + b[i];

Now examine the difference between

  -O2 -funroll-loops -fno-schedule-insns
  -O2 -funroll-loops -fno-schedule-insns -frename-registers

(Turning off sched1 is required because otherwise it will
do all the work, instead of leaving it for regrename.)

This works where the Fortran example doesn't because the C
front end marks the memory references with an alias set that
does not get lost during optimization.


More information about the Gcc-patches mailing list