This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/53383] Allow -mpreferred-stack-boundary=3 on x86-64
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 19 May 2012 21:03:10 +0000
- Subject: [Bug target/53383] Allow -mpreferred-stack-boundary=3 on x86-64
- Auto-submitted: auto-generated
- References: <bug-53383-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> 2012-05-19 21:03:10 UTC ---
With this patch:
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index eca542c..3e4e768 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3660,9 +3660,14 @@ ix86_option_override_internal (bool main_args_p)
ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT;
if (global_options_set.x_ix86_preferred_stack_boundary_arg)
{
- int min = (TARGET_64BIT ? 4 : 2);
+ int min;
int max = (TARGET_SEH ? 4 : 12);
+ if (TARGET_64BIT)
+ min = TARGET_SSE ? 4 : 3;
+ else
+ min = 2;
+
if (ix86_preferred_stack_boundary_arg < min
|| ix86_preferred_stack_boundary_arg > max)
{
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index ddb3645..f7f13d2 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -708,7 +708,7 @@ enum target_cpu_default
#define MAIN_STACK_BOUNDARY (TARGET_64BIT ? 128 : 32)
/* Minimum stack boundary. */
-#define MIN_STACK_BOUNDARY (TARGET_64BIT ? 128 : 32)
+#define MIN_STACK_BOUNDARY (TARGET_64BIT ? (TARGET_SSE ? 128 : 64) : 32)
/* Boundary (in *bits*) on which the stack pointer prefers to be
aligned; the compiler cannot rely on having this alignment. */
I got
[hjl@gnu-mic-2 gcc]$ cat /tmp/x.c
extern __int128 x;
extern void bar (int, int, int, int, int, __int128);
void
foo (void)
{
bar (1, 2, 3, 4, 5, x);
}
[hjl@gnu-mic-2 gcc]$ ./xgcc -B./ -S -O2 /tmp/x.c -mpreferred-stack-boundary=3
-mno-sse
[hjl@gnu-mic-2 gcc]$ cat x.s
.file "x.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movl $5, %r8d
movl $4, %ecx
movl $2, %esi
movl $1, %edi
movq %rsp, %rbp
.cfi_def_cfa_register 6
andq $-16, %rsp
subq $16, %rsp
movq x+8(%rip), %rdx
movq x(%rip), %rax
movq %rdx, 8(%rsp)
movq %rax, (%rsp)
movl $3, %edx
call bar
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (GNU) 4.8.0 20120519 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-mic-2 gcc]$
It looks OK to me.