This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/81445] 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 16:17:42 +0000
- Subject: [Bug middle-end/81445] Dynamic stack allocation not optimized into static allocation
- Auto-submitted: auto-generated
- References: <bug-81445-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81445
--- Comment #2 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #1)
> Note that we already do it for VLA (aka BUILT_IN_ALLOCA_WITH_ALIGN) in CCP.
I don't see it happen for the simplest case in current trunk:
void t(int *);
void vla(void)
{
int x = 100;
int arr[x];
t (arr);
}
void no_vla(void)
{
int arr[100];
t (arr);
}
vla:
stp x29, x30, [sp, -16]!
add x29, sp, 0
sub sp, sp, #416 // alloca
mov x0, sp
bl t
add sp, x29, 0
ldp x29, x30, [sp], 16
ret
no_vla:
stp x29, x30, [sp, -416]!
add x29, sp, 0
add x0, sp, 16
bl t
ldp x29, x30, [sp], 416
ret