From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22168 invoked by alias); 22 Jul 2005 20:10:53 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 22148 invoked by uid 48); 22 Jul 2005 20:10:49 -0000 Date: Fri, 22 Jul 2005 20:15:00 -0000 Message-ID: <20050722201049.22147.qmail@sourceware.org> From: "wilson at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050722045450.22605.ianw@gelato.unsw.edu.au> References: <20050722045450.22605.ianw@gelato.unsw.edu.au> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug middle-end/22605] Alignment of struct on stack is no longer the maxium alignment X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg02777.txt.bz2 List-Id: ------- Additional Comments From wilson at gcc dot gnu dot org 2005-07-22 20:10 ------- I think the 16-byte over-alignment in gcc-3.x is a mis-feature. Anything over 8-byte alignment here is useless. However, I also think the 4-byte alignment in gcc-4.0 is a mis-feature. It just looks wierd to me that we have a 64-bit target with 64-bit stack slots, and we are allocating a 64-bit structure across two stack slots. Yes, what gcc is doing is valid, as the structure has 4-byte alignment. However, that isn't the question here. The question is whether it is desirable. If we over-align the structure to 8-bytes to fit in a single stack slot, then we can use ld8/st8 instructions to copy it around. If we don't over-align it, then we have to copy it by parts which is slower and takes more instructions. On a target like IA-64 where performance is more important than memory usage, it appears that we have made the wrong choice here. I think over-aligning to 8-bytes in this case will give better (faster) code at the cost of a negligible frame size increase. We have target macros like DATA_ALIGNMENT and CONSTANT_ALIGNMENT so that we can give extra alignment in cases where we know this will improve performance. But we have no such macro for variables allocated on the stack. In the past, we probably didn't need one, because we were already over-aligning structures on the stack by default. Now that we don't over-align on the stack by default, maybe we should have one. I haven't done any study to see whether this is beneficial. This might be a interesting little optimization project for someone to try. If an aggregate allocated on the stack has alignment less than the word size, but has size equal to or larger than the word size, then try over-aligning to the word size, and see if this affects SPEC results on a STRICT_ALIGNMENT target. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22605