This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/81445] New: Dynamic stack allocation not optimized into static allocation
- From: "wilco at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Jul 2017 13:41:18 +0000
- Subject: [Bug middle-end/81445] New: Dynamic stack allocation not optimized into static allocation
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81445
Bug ID: 81445
Summary: Dynamic stack allocation not optimized into static
allocation
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: wilco at gcc dot gnu.org
Target Milestone: ---
Many compilers optimize small dynamic allocations into static allocation. This
is more efficient as it allows multiple small dynamic allocations to be merged
into a single static allocation. In some cases it may remove all dynamic
allocations, avoiding the need for a frame pointer (which frees up an extra
register on various targets in addition to reducing prolog/epilog overheads).
Obviously allocations cannot be in a loop (including tail-recursion), and the
total size should be limited to avoid increasing stack size by too much.
void f(void*);
void alloca (int x)
{
if (x < 100)
f (__builtin_alloca (x));
f (__builtin_alloca (16));
}