public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Backend port: Minimizing register usage in favor of memory accesses
@ 2004-03-30 17:48 xyzzy
  2004-03-31  1:43 ` Joern Rennecke
  2004-03-31  1:48 ` Jim Wilson
  0 siblings, 2 replies; 8+ messages in thread
From: xyzzy @ 2004-03-30 17:48 UTC (permalink / raw)
  To: GCC list

I understand that one of the goals of any optimizing compiler is to maximize 
use of registers since this is the fastest and least space consuming type of 
instruction on most processors.

Thus, C code like:

extern void bar();
int a,b;
foo()
{
	a = 5;
	if ( b > a )
		bar();
}

... produces pseudo-code like:
.word a,b
	move 5,tmp1reg
	move tmp1reg,a

	move b,tmp2reg
	cmp tmp2reg,tmp1reg
	bgt label1
	call bar
label1:
	ret

What I want to do is reverse this and minimize register usage as much as 
possible, massively favoring memory accesses unless a register absolutely 
MUST be used.  Thus, I want my backend to produce code like this:

.word a,b
	move 5,a
	cmp b,a
	bgt label1
	call bar
label1:
	ret

Is there any way to force the GCC backend to do this, if at all?  Will 
defining SMALL_REGISTER_CLASSES to 1 do the trick or is there any other magic 
that can be invoked?  Doing it in the optimizer stage is OK, too... if O2 or 
less.

Many thanks for any help on this.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-04-01 19:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-30 17:48 Backend port: Minimizing register usage in favor of memory accesses xyzzy
2004-03-31  1:43 ` Joern Rennecke
2004-03-31  1:48 ` Jim Wilson
2004-03-31 12:23   ` xyzzy
2004-04-01 19:48     ` Jim Wilson
2004-03-31 12:53   ` Richard Earnshaw
2004-03-31 13:05     ` xyzzy
2004-03-31 13:49     ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).