Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: Predict reg...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 7 Topic 2395 of 2534
Post > Topic >>

Re: Predict register usage

by Chris F Clark <cfc@[EMAIL PROTECTED] > Apr 25, 2008 at 11:36 PM

Tim Frink <plfriko@[EMAIL PROTECTED]
> writes:

> When the optimization inline extension is performed on a high-level
> intermediate representation or on a low-level IR before register
> allocation, the final result for the inlined code after the register
> allocation is not known. Thus, it might happen that due to the
> increased register pressure after inlining, spill code must be added
> heavily leading to a worse performance than before the
> optimization. Do you know of any approaches which try to predict the
> resulting spill code added by a register allocation when inlining is
> done for a particular function?

> My idea was that lifetime analyses might be used for that
> purpose. One could find out how many variables (in high-level) or
> register are life across a call. This is an indication for spill
> code candidates. Based on this one could develop some heuristics
> that omit inlining for functions that are supposed to add too much
> spilling. What do you think about this idea?

While this seems like it would be useful, to understand the tradeoff
you have to consider what happens if you don't inline the function and
in fact call the function.

If the variable is held in a caller-save register, then the caller
must spill the register before the call, thus you haven't saved
executing any spill code.  Similarly, if the variable is held in a
callee-save register and the possibly-to-be-inlined function uses the
register, the function needs to save the register even if called and
no spill code has been saved.

The one calling (register based) convention that I'm aware of where
you might not need spill code by doing a call, is if the architecture
sup****ts a rotating register window.  In that case, the hardware
itself will take care of the spills.

Now, it wouldn't surprise me to learn of other calling conventions
where a call doesn't require spills, but caller and callee-save
registers are the most popular, and in both of those cases you won't
save spills by not inlining the call.  In fact, when I was doing code
generator and optimizer work, it was often worth inlining the call
even if the only improvement was the elimination of superfluous spills
that the calling convention required.

Hope this helps,
-Chris

******************************************************************************
Chris Clark              Internet:
christopher.f.clark@[EMAIL PROTECTED]
 Resources, Inc.       or: compres@[EMAIL PROTECTED]
 Bailey Rd             Web Site: http://world.std.com/~compres
Berlin, MA  01503           voice:  (508) 435-5016
USA                           fax:  (978) 838-0263  (24 hours)
 




 7 Posts in Topic:
Predict register usage
Tim Frink <plfriko@[EM  2008-04-25 13:56:25 
Re: Predict register usage
Chris F Clark <cfc@[EM  2008-04-25 23:36:26 
Re: Predict register usage
andreybokhanko@[EMAIL PRO  2008-05-02 00:35:46 
Predict register usage
"Inderaj Bains"  2008-04-26 10:01:47 
Re: Predict register usage
Sid Touati <SidTouati@  2008-04-28 12:11:26 
Re: Predict register usage
andreybokhanko@[EMAIL PRO  2008-05-02 00:33:54 
Re: Predict register usage
=?ISO-8859-1?Q?Bj=F6rn_Fr  2008-05-09 15:33:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:25:43 CDT 2008.