http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58817
Bug ID: 58817 Summary: optimize alloca with constant size Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Hello, I thought gcc already had this optimization but apparently not. We don't produce the same code with alloca and with arrays: void f(int*); void g(){ #if 1 const int n=4; int a[n]; #elif 1 int a[4]; #else int*a=__builtin_alloca(16); #endif f(a); } possibly because arrays give alloca_with_align, not alloca. There may be reasons why the transformation would be illegal though, I am not sure.