RISC perspective

tgg at hou5e.UUCP tgg at hou5e.UUCP
Wed Mar 14 10:21:02 AEST 1984


>The idea is good, but there's one problem with its current implementation;
>there's no way to make those hints truly "machine-independent".  The problem
>is that you want to use all the registers you can (actually, there's even
>a tradeoff here; you get extra performance from instructions referencing
>registers, but you do have to save and restore those registers, and if you
>have complicated expressions you may run out of scratch registers and be
>forced to use temporaries in memory), but "all the registers you can" is
>machine-dependent.  On the PDP-11, "all the registers you can" in the Ritchie
>and Johnson compilers is 3; on the VAX-11, it's 6, and on the M68000, it's
>(at least on our compiler) 6 registers not containing pointers and four
>registers containing pointers.  Just declaring everything you can to be
>"register" wins only if 1) there are enough registers to satisfy your requests
>or 2) the variables that will cause the greatest improvement when put in
>registers are assigned to registers first, and the less important ones cause
>the compiler to ignore the "register" declaration.
>
>
>	Guy Harris
>	{seismo,ihnp4,allegra}!rlgvax!guy

No no no - you're taking the meaning of 'register' too literally! It does not
mean that the compiler is forced to use a register for these variables, it just
means that you're giving it a hint that these variables are more likely to
be referenced than other variables. If that means that, for the machine at
hand, the variables should be three's complimented and stored in reverse bit
order starting at memory location 3fd3.8 (octal) because that is the absolute
best place to store an integer for speedy calculations, then the compiler
should do that for 'register' variables. Let the compiler worry about what
to do if it runs out of registers or other resources.

The point is that 'register' exists to differentiate some variables from
others so that a compiler can make some reasonable tradeoffs if possible.
Making every variable in a program 'register' isn't any good because their
*all* important. If you want overall optimization, make a better optimizer.

Personally, I think that 'register' should have been changed to 'fast' or
something like it long ago...
	Tom Gulvin		ABI - Holmdel



More information about the Comp.lang.c mailing list