i386 common data alignment patch

John Wehle john@feith.com
Sun Apr 26 19:13:00 GMT 1998


Hello,

This change implements the alignment of common data following
the recommendations of the "Intel Architecture Optimization Manual".
This change seem to be worth about 11% speed increase on the
double precision whetstone benchmark.

ChangeLog:

Sat Apr 25 20:15:03 EDT 1998  John Wehle  (john@feith.com)

	* varasm.c (assemble_variable): Use BSS_ALIGNMENT if defined.
	* tm.texi: Document BSS_ALIGNMENT.
	* i386.h (BSS_ALIGNMENT): Define.

Notes:

  1) This patch expects that the i386.h DATA_ALIGNMENT has already
     been installed.

  2) This patch will only have an effect on platforms which allow
     the alignment to be specified for a common variable.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/varasm.c.ORIGINAL	Fri Mar 20 09:58:41 1998
--- gcc/varasm.c	Thu Apr 23 16:46:30 1998
***************
*** 1307,1312 ****
--- 1307,1319 ----
  	data_section ();
  #endif
  
+ #ifdef BSS_ALIGNMENT
+       /* On some machines, it is good to increase alignment sometimes.  */
+       align = DECL_ALIGN (decl);
+       align = BSS_ALIGNMENT (TREE_TYPE (decl), align);
+       DECL_ALIGN (decl) = align;
+ #endif
+ 
        if (TREE_PUBLIC (decl)
  #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
  	  && DECL_COMMON (decl)
*** gcc/tm.texi.ORIGINAL	Mon Mar 16 06:56:10 1998
--- gcc/tm.texi	Sat Apr 25 20:13:20 1998
***************
*** 837,842 ****
--- 837,854 ----
  constants to be word aligned so that @code{strcpy} calls that copy
  constants can be done inline.
  
+ @findex BSS_ALIGNMENT
+ @item BSS_ALIGNMENT (@var{type}, @var{basic-align})
+ If defined, a C expression to compute the alignment for a common
+ variable.  @var{type} is the data type, and @var{basic-align} is the
+ alignment that the object would ordinarily have.  The value of this
+ macro is used instead of that alignment to align the object.
+ 
+ If this macro is not defined, then @var{basic-align} is used.
+ 
+ The typical use of this macro is to increase alignment of medium-size
+ data to make it all fit in fewer cache lines.
+ 
  @findex EMPTY_FIELD_BOUNDARY
  @item EMPTY_FIELD_BOUNDARY
  Alignment in bits to be given to a structure bit field that follows an
*** gcc/config/i386/i386.h.ORIGINAL	Sat Apr 25 20:23:33 1998
--- gcc/config/i386/i386.h	Sat Apr 25 20:27:42 1998
***************
*** 475,480 ****
--- 475,492 ----
  	: (ALIGN))							\
      : (ALIGN))
  
+ /* If defined, a C expression to compute the alignment for a common
+    variable.  TYPE is the data type, and ALIGN is the alignment that
+    the object would ordinarily have.  The value of this macro is used
+    instead of that alignment to align the object.
+ 
+    If this macro is not defined, then ALIGN is used.
+ 
+    The typical use of this macro is to increase alignment of medium-size
+    data to make it all fit in fewer cache lines.  */
+ 
+ #define BSS_ALIGNMENT(TYPE, ALIGN)	DATA_ALIGNMENT(TYPE, ALIGN)
+ 
  /* Set this non-zero if move instructions will actually fail to work
     when given unaligned data.  */
  #define STRICT_ALIGNMENT 0
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------




More information about the Gcc-bugs mailing list