stack height reduction in tree-SSA

Joseph S. Myers jsm@polyomino.org.uk
Wed Sep 1 10:40:00 GMT 2004


On Wed, 1 Sep 2004, Giovanni Bajo wrote:

> void foo(void)
> {
>    int a, b;
> 
>    a = get();
>    use_it(&a);
> 
>    b = get();
>    use_it(&b);
> }
> 
> could be optimized to use only one variable on the stack. I have the secret

In this example, a is still live during the second calls to get() and 
use_it(); the first call to use_it() could have saved a's address.

A variable's life won't exceed its scope (meaning the block in which it is 
declared, including the parts before its declaration) even if its address 
is taken.  If its address is not taken (or if the address is taken but 
only in such a way as not to escape) then you can ignore the scope and 
just observe when it is live.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 3.5
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)



More information about the Gcc mailing list