Related articles |
---|
Register pressure and inlining linuxkaffee_@_gmx.net (Stephan Ceram) (2008-11-08) |
Re: Register pressure and inlining jeremy.wright@microfocus.com (Jeremy Wright) (2008-11-09) |
RE: Register pressure and inlining murugesh@acmet.com (Murugesh) (2008-11-10) |
RE: Register pressure and inlining murugesh@acmet.com (Murugesh) (2008-11-10) |
Re: Register pressure and inlining liangkun1983@gmail.com (Alex L.K) (2008-11-12) |
Re: Register pressure and inlining armelasselin@hotmail.com (Armel) (2008-11-12) |
Re: Register pressure and inlining bear@sonic.net (Ray Dillinger) (2008-11-12) |
[2 later articles] |
From: | Stephan Ceram <linuxkaffee_@_gmx.net> |
Newsgroups: | comp.compilers |
Date: | 8 Nov 2008 10:24:02 GMT |
Organization: | Compilers Central |
Keywords: | registers, optimize, question |
Posted-Date: | 08 Nov 2008 11:19:49 EST |
Hi,
In context with the optimization "function inlining" you often read
that inlining of a function increases the register pressure which may
possibly lead to the generation of additional spill code. I don't
understand why.
Let's say, I've a function foo and foo2 and registers r1, r2 are
caller-saved registers, while r3 is callee-save and let's assume that
these 3 registers are the only available physical registers. So the
code including the save and restore of the registers across a call
would look something like:
foo:
define r1
define r2
STORE r1 # Caller-save
STORE r2 # Caller-save
call foo2
RESTORE r2
RESTORE r1
use r2
use r1
return
foo2:
STORE r3 # Calle-save
define r1
define r3
use r1
use r3
RESTORE r3
return
So I have three STORE/RESTORE pairs which correspond to spill
code. When I inline function foo2 into foo I get:
foo:
define r1
define r2
STORE r1 # Caller-save
define r1 # foo2
define r3 # foo2
use r1 # foo2
use r3 # foo2
use r2
RESTORE r1
use r1
return
So, in my case with a high register pressure in function foo, inlining
of function foo2 did even more increase the register pressure due to
r1. But, in total the number of spill instruction did _not_ increase
but got reduced by 2/3. The reason is obviously the context save
across the call. Did I miss something? Or can you explain to me when
function inlining will lead to additional spill code having a negative
effect on the program performance?
Regards,
Stephan
Return to the
comp.compilers page.
Search the
comp.compilers archives again.