This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Backend port: Minimizing register usage in favor of memory accesses


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]