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