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

Chris Sears cbsears_sf@yahoo.com
Tue Jan 15 03:46:00 GMT 2002


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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386.c.PATCH
Type: application/octet-stream
Size: 428 bytes
Desc: i386.c.PATCH
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20020115/b7e21e86/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xx.c
Type: application/octet-stream
Size: 202 bytes
Desc: xx.c
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20020115/b7e21e86/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xx.s.orig
Type: application/octet-stream
Size: 644 bytes
Desc: xx.s.orig
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20020115/b7e21e86/attachment-0002.obj>


More information about the Gcc mailing list