On Tue, Jan 14, 2014 at 08:12:41PM +0100, Jakub Jelinek wrote:
> For 4.9, if what you've added is what you want to do for performance
> reasons, then I'd do something like:

Ok, here it is in a form of patch, bootstrapped/regtested on x86_64-linux
and i686-linux, ok for trunk?

2014-01-17  Jakub Jelinek  <ja...@redhat.com>

        * config/i386/i386.c (ix86_data_alignment): For compatibility with
        (incorrect) GCC 4.8 and earlier alignment assumptions ensure we align
        decls to at least the GCC 4.8 used alignments.

--- gcc/config/i386/i386.c.jj   2014-01-16 20:22:50.000000000 +0100
+++ gcc/config/i386/i386.c      2014-01-17 11:56:51.183501322 +0100
@@ -26433,6 +26433,15 @@ ix86_constant_alignment (tree exp, int a
 int
 ix86_data_alignment (tree type, int align, bool opt)
 {
+  /* GCC 4.8 and earlier used to incorrectly assume this alignment even
+     for symbols from other compilation units or symbols that don't need
+     to bind locally.  In order to preserve some ABI compatibility with
+     those compilers, ensure we don't decrease alignment from what we
+     used to assume.  */
+
+  int max_align_compat
+    = optimize_size ? BITS_PER_WORD : MIN (256, MAX_OFILE_ALIGNMENT);
+
   /* A data structure, equal or greater than the size of a cache line
      (64 bytes in the Pentium 4 and other recent Intel processors, including
      processors based on Intel Core microarchitecture) should be aligned
@@ -26447,11 +26456,17 @@ ix86_data_alignment (tree type, int alig
   if (opt
       && AGGREGATE_TYPE_P (type)
       && TYPE_SIZE (type)
-      && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-      && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= (unsigned) max_align
-         || TREE_INT_CST_HIGH (TYPE_SIZE (type)))
-      && align < max_align)
-    align = max_align;
+      && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
+    {
+      if ((TREE_INT_CST_LOW (TYPE_SIZE (type)) >= (unsigned) max_align_compat
+          || TREE_INT_CST_HIGH (TYPE_SIZE (type)))
+         && align < max_align_compat)
+       align = max_align_compat;
+      if ((TREE_INT_CST_LOW (TYPE_SIZE (type)) >= (unsigned) max_align
+          || TREE_INT_CST_HIGH (TYPE_SIZE (type)))
+         && align < max_align)
+       align = max_align;
+    }
 
   /* x86-64 ABI requires arrays greater than 16 bytes to be aligned
      to 16byte boundary.  */


        Jakub

Reply via email to