From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24760 invoked by alias); 17 May 2008 00:18:02 -0000 Received: (qmail 24188 invoked by uid 48); 17 May 2008 00:17:16 -0000 Date: Sat, 17 May 2008 00:18:00 -0000 Subject: [Bug middle-end/36253] New: Caller-save stack slot may not have proper alignment X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "hjl dot tools at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-05/txt/msg01269.txt.bz2 setup_save_areas calls assign_stack_local to allocate a stack slot for a hard register in the widest mode. assign_stack_local has if (align == 0) { tree type; if (mode == BLKmode) alignment = BIGGEST_ALIGNMENT; else alignment = GET_MODE_ALIGNMENT (mode); /* Allow the target to (possibly) increase the alignment of this stack slot. */ type = lang_hooks.types.type_for_mode (mode, 0); if (type) alignment = LOCAL_ALIGNMENT (type, alignment); alignment /= BITS_PER_UNIT; } For x87, the widest mode is XF, which is 12byte aligned at 4 byte. So a 12byte stack slot aligned at 4 byte is allocated for an x87 register. For x87, DF is 8 byte aligned at 8 byte. If it turns out later that we need to save/restore DF instead XF, we load/store the DF register at 4 byte instead of 8 byte. It won't give us the best x87 performance. One fix is change if (type) alignment = LOCAL_ALIGNMENT (type, alignment); to alignment = LOCAL_ALIGNMENT (type, mode, alignment); If type is NULL, it is used for stack slot. We can return proper alignment based on mode. -- Summary: Caller-save stack slot may not have proper alignment Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hjl dot tools at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36253