Improve alloca alignment
commitef6533727511b05fd7e4c7325bf822f4fc1ae4d8
authorwilco <wilco@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Sep 2017 13:27:58 +0000 (5 13:27 +0000)
committerwilco <wilco@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Sep 2017 13:27:58 +0000 (5 13:27 +0000)
tree7280c7e1c75597c2c29f62ff781b46e1369249c9
parent3daf52f78423515253c156cf5adc94d5e6b00994
Improve alloca alignment

This patch improves alloca alignment.  Currently alloca reserves
too much space as it aligns twice, and generates unnecessary stack
alignment code.

When the requested alignment is lower than the stack alignment, no
extra alignment is needed.  If the requested alignment is higher,
we need to increase the size by the difference of the requested
alignment and the stack alignment.  As a result, the alloca alignment
is exactly as expected:

alloca (16):
sub sp, sp, #16
mov x1, sp

alloca (x):
add x0, x0, 15
and x0, x0, -16
sub sp, sp, x0
mov x0, sp

__builtin_alloca_with_align (x, 512):
add x0, x0, 63
and x0, x0, -16
sub sp, sp, x0
add x0, sp, 63
and x0, x0, -64

    gcc/
* explow.c (get_dynamic_stack_size): Improve dynamic alignment.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251713 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/explow.c