From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1067 invoked by alias); 23 Jul 2007 23:05:18 -0000 Received: (qmail 1055 invoked by uid 22791); 23 Jul 2007 23:05:17 -0000 X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 23 Jul 2007 23:05:12 +0000 Received: from localhost (camellia.ms.mff.cuni.cz [195.113.18.73]) by nikam.ms.mff.cuni.cz (Postfix) with ESMTP id CFC415BA1E; Tue, 24 Jul 2007 01:05:03 +0200 (CEST) Received: by localhost (Postfix, from userid 16202) id BF6628B74E; Tue, 24 Jul 2007 01:05:03 +0200 (CEST) Date: Tue, 24 Jul 2007 00:54:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, ak@suse.de Subject: Allow preferred-stack-boundary of 3 for x86-64 Message-ID: <20070723230503.GA10270@kam.mff.cuni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg01699.txt.bz2 Hi, Andi Kleen raised point that while x86-64 ABI requires 16byte alignment, kernel preffers to save stack psace by 8 byte alignment even though it breaks some of features (such as XMM support or variadic arguments of types aligned to 16 bytes, such as long double). This patch thus makes GCC to tolerate this option and updates documentation accrodingly. I will install it tomorrow if there are no complains. Bootstrapped/regtested i686-linux. Honza * i386.c (override_options): Allow preferred stack boundary of 3 for x86-64. * doc/invoke.texi (preferred-stack-boundary): Document. Index: config/i386/i386.c =================================================================== *** config/i386/i386.c (revision 126800) --- config/i386/i386.c (working copy) *************** override_options (void) *** 2324,2332 **** if (ix86_preferred_stack_boundary_string) { i = atoi (ix86_preferred_stack_boundary_string); ! if (i < (TARGET_64BIT ? 4 : 2) || i > 12) error ("-mpreferred-stack-boundary=%d is not between %d and 12", i, ! TARGET_64BIT ? 4 : 2); else ix86_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT; } --- 2324,2332 ---- if (ix86_preferred_stack_boundary_string) { i = atoi (ix86_preferred_stack_boundary_string); ! if (i < (TARGET_64BIT ? 3 : 2) || i > 12) error ("-mpreferred-stack-boundary=%d is not between %d and 12", i, ! TARGET_64BIT ? 3 : 2); else ix86_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT; } Index: doc/invoke.texi =================================================================== *** doc/invoke.texi (revision 126800) --- doc/invoke.texi (working copy) *************** libraries that use callbacks always use *** 10323,10329 **** This extra alignment does consume extra stack space, and generally increases code size. Code that is sensitive to stack space usage, such as embedded systems and operating system kernels, may want to reduce the ! preferred alignment to @option{-mpreferred-stack-boundary=2}. @item -mmmx @itemx -mno-mmx --- 10323,10337 ---- This extra alignment does consume extra stack space, and generally increases code size. Code that is sensitive to stack space usage, such as embedded systems and operating system kernels, may want to reduce the ! preferred alignment to @option{-mpreferred-stack-boundary=2} ! or @option{-mpreferred-stack-boundary=3}. ! ! The 64bit SYSV ABI require at lest 16-byte alignment. Specifying ! @option{-mpreferred-stack-boundary=3} is accepted by compiler, but will result ! in misaligning the stack. Calling functions with misaligned stack will break ! spilling of SSE registers as well as varargs of types with 16-byte alignment. ! It may be however viable alternative for stack space constrained environments. ! @item -mmmx @itemx -mno-mmx Index: config/i386/i386.h =================================================================== *** config/i386/i386.h (revision 126800) --- config/i386/i386.h (working copy) *************** extern const char *host_detect_local_cpu *** 775,781 **** /* Target OS keeps a vector-aligned (128-bit, 16-byte) stack. This is mandatory for the 64-bit ABI, and may or may not be true for other operating systems. */ ! #define TARGET_KEEPS_VECTOR_ALIGNED_STACK TARGET_64BIT /* Minimum allocation boundary for the code of a function. */ #define FUNCTION_BOUNDARY 8 --- 775,782 ---- /* Target OS keeps a vector-aligned (128-bit, 16-byte) stack. This is mandatory for the 64-bit ABI, and may or may not be true for other operating systems. */ ! #define TARGET_KEEPS_VECTOR_ALIGNED_STACK \ ! (TARGET_64BIT && ix86_preferred_stack_boundary >= 4) /* Minimum allocation boundary for the code of a function. */ #define FUNCTION_BOUNDARY 8