does gcc remember register values through into functions?

Steven Bosscher stevenb@suse.de
Mon Jan 17 12:26:00 GMT 2005


On Monday 17 January 2005 07:09, Lin Gu wrote:
> char a;
>
> void f()
> {
>   a++;
> }
>
> int main()
> {
>   a = 252;
>   f();
> }
>
>
> If gcc chooses a register r16 to store a's value,
> can gcc use r16 directly in the compiled code
> of function f, so that it avoids a memory load
> for variable a? This optimization should be valid
> if f is only called in main.

This is a form of interprocedural register allocation.  GCC does
not do this.

Gr.
Steven



More information about the Gcc mailing list