Re: optimize malloc to stack allocation.

2013-01-09 Thread Richard Biener
On Wed, Jan 9, 2013 at 5:33 PM, Ondřej Bílka wrote: > On Wed, Jan 09, 2013 at 05:12:06PM +0100, Marc Glisse wrote: >> On Wed, 9 Jan 2013, Ondřej Bílka wrote: >> >> >gcc currently does not even optimize following fragment: >> > >> >int foo(){ >> > char *x=malloc(64); >> > free(x); >> >} >> >> Yes i

Re: optimize malloc to stack allocation.

2013-01-09 Thread Ondřej Bílka
On Wed, Jan 09, 2013 at 05:12:06PM +0100, Marc Glisse wrote: > On Wed, 9 Jan 2013, Ondřej Bílka wrote: > > >gcc currently does not even optimize following fragment: > > > >int foo(){ > > char *x=malloc(64); > > free(x); > >} > > Yes it does. > (not that more optimizations aren't possible, but it

Re: optimize malloc to stack allocation.

2013-01-09 Thread Marc Glisse
On Wed, 9 Jan 2013, Ondřej Bílka wrote: gcc currently does not even optimize following fragment: int foo(){ char *x=malloc(64); free(x); } Yes it does. (not that more optimizations aren't possible, but it does this one) -- Marc Glisse

optimize malloc to stack allocation.

2013-01-09 Thread Ondřej Bílka
Hello, gcc currently does not even optimize following fragment: int foo(){ char *x=malloc(64); free(x); } It should be possible to change malloc with small size and there is free that dominates that malloc into alloca. Also when size it is not known it could be (perhaps with profiling) tur