This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] i386.c string alignment - no alignment for < 32 bytes, else to 32 bytes



This is a patch for gcc-3.0.3/gcc/config/i386/i386.c.

gcc has a bug with string alignment on the x86.  For short strings,
it doesn't align at all.  For strings longer than 32 bytes,
it needlessly aligns them to 32 bytes. NB: this is only on the x86.

Attached is a patch file, a simple test case, and the disassembly
before the patch.

The easiest way to see the problem is to look at the disassembly.
Also, compare the CONSTANT_ALIGNMENT macro in any of the other ports
with ix86_constant_alignment().
*Also* for all ports, gcc aligns the constants in some declarations
to a cache line, usually 32 bytes.  This is a result of some,
in my opinion, weak logic in varasm.c: (simplified)

/* On some machines, it is good to increase alignment sometimes.  */
align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
  align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);

I'm not submitting a patch for this because I don't understand it
well enough yet.  But perhaps someone can help me.

Chris Sears
cbsears_sf@yahoo.com

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

Attachment: i386.c.PATCH
Description: i386.c.PATCH

Attachment: xx.c
Description: xx.c

Attachment: xx.s.orig
Description: xx.s.orig


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]