public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: xyzzy@hotpop.com
To: GCC list <gcc@gcc.gnu.org>
Subject: Backend port: Minimizing register usage in favor of memory accesses
Date: Tue, 30 Mar 2004 17:48:00 -0000	[thread overview]
Message-ID: <200403301148.19194.xyzzy@hotpop.com> (raw)

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.

             reply	other threads:[~2004-03-30  9:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-30 17:48 xyzzy [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200403301148.19194.xyzzy@hotpop.com \
    --to=xyzzy@hotpop.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).