This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/55945] New: alloca aligns aligned pointers
- From: "neleai at seznam dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Jan 2013 19:51:38 +0000
- Subject: [Bug target/55945] New: alloca aligns aligned pointers
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55945
Bug #: 55945
Summary: alloca aligns aligned pointers
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: neleai@seznam.cz
Alloca returns 16 byte aligned pointers on x64. However it does unnecessary
instructions.
Consider following example.
int foo(){
char *a=alloca(64),*b=alloca(64),*c=alloca(64);
bar(a,b,c);
}
Resulting assembly does not use that rsp is already 16 byte aligned nor that
intermediate results are 16 byte aligned.
pushq %rbp
xorl %eax, %eax
movq %rsp, %rbp
subq $80, %rsp
leaq 15(%rsp), %rdi
subq $80, %rsp
leaq 15(%rsp), %rsi
subq $80, %rsp
leaq 15(%rsp), %rdx
andq $-16, %rdi
andq $-16, %rsi
andq $-16, %rdx
call bar
leave
Moreover it is suboptimal for stacks growing down as
subq cnt, %rsp
andq $-16, %rsp
is more effective way.