------- Comment #31 from Joey dot ye at intel dot com 2009-02-23 03:15 ------- How about this patch? 1. Only reduce DI mode when -Os 2. Ignore TYPE_USER_ALIGN, so that stack realign happens for case in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39137#c28, which IMHO is acceptable. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 5221) +++ config/i386/i386.c (working copy) @@ -19607,6 +19607,13 @@ ix86_local_alignment (tree type, enum machine_mode mode, unsigned int align) { + /* We don't want to align DImode to 64bit for compilation with + -mpreferred-stack-boundary=2 to not enforce dynamic stack alignment + prologue. */ + if (mode == DImode && !TARGET_64BIT && ix86_preferred_stack_boundary < 64 + && optimize_function_for_size_p (cfun)) + align = 32; + /* If TYPE is NULL, we are allocating a stack slot for caller-save register in MODE. We will return the largest alignment of XF and DF. */ @@ -19616,6 +19623,12 @@ align = GET_MODE_ALIGNMENT (DFmode); return align; } + if (!TARGET_64BIT + && optimize_function_for_size_p (cfun) + && align == 64 + && ix86_preferred_stack_boundary < 64 + && (mode == DImode || (type && TYPE_MODE (type) == DImode))) + align = 32;
/* x86-64 ABI requires arrays greater than 16 bytes to be aligned to 16byte boundary. */ -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39137