new-ra code sizes on Hitachi H8

Kazu Hirata kazu@cs.umass.edu
Thu Feb 13 23:06:00 GMT 2003


Hi Toshi,

> The H8 has always seemed to have code size issues. The cause seems to be
> the following two items in tandem:
> 
> 1) Only 8 general purpose registers
> 
> 2) The instructions for spilling/restoring registers to/from the stack are
>    6 bytes - mov.l ers,@(d:16,erd) and mov.l @(d:16,ers),erd

I don't know how much the following problem contributes, but let me
mention it anyway.

int
foo (float a, float b)
{
  return a < b;
}

gets compiled to

_foo:
	mov.l	er4,@-er7
	sub.w	r4,r4
	jsr	@___ltsf2
	mov.l	er0,er0
	bge	.L2
	adds	#1,er4
.L2:
	mov.w	r4,r0
	mov.l	@er7+,er4
	rts

Notice the initialization of r4 can be delayed after calling ___ltsf2.
That in turn allows us to rename r4 with r2 or something so that I
don't have save and restore er4 at the beginning.

Is there any infrastructure or pass in gcc that moves assignments
closer to users?  I guess this is a double-edged sword.  If the
assignment and the use are too close on a pipelined machine, the
processor might stall.  (On H8, this is always welcome.)  But then if
you can reduce the distance between def and use, you reduce the
register pressure.

Kazu Hirata



More information about the Gcc mailing list