This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/28074] -mstackrealign generates inefficient code
- From: "hjl at lucon dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Oct 2007 15:21:59 -0000
- Subject: [Bug target/28074] -mstackrealign generates inefficient code
- References: <bug-28074-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from hjl at lucon dot org 2007-10-06 15:21 -------
(In reply to comment #3)
> The testcase is slightly uninformative.
>
> Note, that %esp is aligned here and %ebp is potentially not (thus locals are
> accessed via %esp).
>
> What if:
>
> 1. We have dinamic size alloca() call
> 2. We have incoming arguments. How are they referenced? Via %ebp?
%ebp isn't really required since -fomit-frame-pointer works for x86. We
have the original stack pointer in %ebp, which can be used to access
arguments. The aligned stack pointer in %esp can be used for local.
[hjl@gnu-6 align-4]$ cat x.c
#include <emmintrin.h>
extern void bar (char *);
char *
e1 (float x, char *p)
{
volatile __m128 dummy = _mm_set_ps1(x);
char foo [0];
bar (foo);
return p;
}
[hjl@gnu-6 align-4]$ /opt/intel/cc/10.0/bin/icc -S -O x.c
[hjl@gnu-6 align-4]$ cat icc.s
e1:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
movss 8(%ebp), %xmm0
lea 16(%esp), %eax
unpcklps %xmm0, %xmm0
unpcklps %xmm0, %xmm0
movaps %xmm0, (%esp)
pushl %eax
call bar
popl %ecx
movl 12(%ebp), %eax
movl %ebp, %esp
popl %ebp
ret
[hjl@gnu-6 align-4]$ /usr/gcc-4.3/bin/gcc -m32 -O -msse2 -S -mstackrealign x.c
[hjl@gnu-6 align-4]$ cat gcc.s
e1:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
subl $40, %esp
movl %ecx, -8(%ebp)
movl %ebx, -4(%ebp)
movss (%ecx), %xmm0
movl 4(%ecx), %ebx
shufps $0, %xmm0, %xmm0
movaps %xmm0, -24(%ebp)
leal -24(%ebp), %eax
movl %eax, (%esp)
call bar
movl %ebx, %eax
movl -8(%ebp), %ecx
movl -4(%ebp), %ebx
movl %ebp, %esp
popl %ebp
leal -4(%ecx), %esp
ret
[hjl@gnu-6 align-4]$
As you can see, icc generate much cleaner codes than gcc.
--
hjl at lucon dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xuepeng dot guo at intel dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28074