re PR tree-optimization/52571 (vectorizer changes alignment of common symbols)
authorRichard Guenther <rguenther@suse.de>
Wed, 14 Mar 2012 13:00:44 +0000 (13:00 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 14 Mar 2012 13:00:44 +0000 (13:00 +0000)
2012-03-14  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/52571
* tree-vect-data-refs.c (vect_compute_data_ref_alignment): Move
flag_section_anchors check ...
(vect_can_force_dr_alignment_p): ... here.  Do not re-align
DECL_COMMON variables.

* gcc.dg/vect/vect-2.c: Initialize arrays.
* gcc.dg/vect/no-section-anchors-vect-34.c: Likewise.
* gcc.target/i386/recip-vec-divf.c: Use -fno-common.
* gcc.target/i386/recip-vec-sqrtf.c: Likewise.

From-SVN: r185380

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-34.c
gcc/testsuite/gcc.dg/vect/vect-2.c
gcc/testsuite/gcc.target/i386/recip-vec-divf.c
gcc/testsuite/gcc.target/i386/recip-vec-sqrtf.c
gcc/tree-vect-data-refs.c

index 04e1a00e07bafb5b32ca54495a8872c63e0380e9..3eaf56481858361f456a46a4917aa54c9d45d64d 100644 (file)
@@ -1,3 +1,11 @@
+2012-03-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/52571
+       * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Move
+       flag_section_anchors check ...
+       (vect_can_force_dr_alignment_p): ... here.  Do not re-align
+       DECL_COMMON variables.
+
 2012-03-14  Richard Guenther  <rguenther@suse.de>
 
        * tree.h (DECL_BIT_FIELD_REPRESENTATIVE): New define.
index 406f0959f51587e0b2f3b9e4db99d3d2055a80f7..1ce4c103a128fc4a085d3a19193fd3de64b066dc 100644 (file)
@@ -1,3 +1,11 @@
+2012-03-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/52571
+       * gcc.dg/vect/vect-2.c: Initialize arrays.
+       * gcc.dg/vect/no-section-anchors-vect-34.c: Likewise.
+       * gcc.target/i386/recip-vec-divf.c: Use -fno-common.
+       * gcc.target/i386/recip-vec-sqrtf.c: Likewise.
+
 2012-03-14  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/52080
index 2eac33e414b6b35a7b615363d4f8ac2312e0dbfb..7600edf160d0e166182f5998db9732f9aa81fecf 100644 (file)
@@ -7,7 +7,7 @@
  
 struct {
   char ca[N];
-} s;
+} s = {};
 char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
 
 __attribute__ ((noinline))
index 5d4fc914a970dd6ee73d1581dd30153a5aac8b3d..f01b7b46ddc6c9c11df4a5108d9d72af20659def 100644 (file)
@@ -6,7 +6,7 @@
 #define N 16
 
 char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
-char ca[N];
+char ca[N] = {};
 
 __attribute__ ((noinline)) 
 int main1 ()
index 0c0cd42ae8ac54bae566eaf5e64c9d4e09b528ee..fa126e45f6fd8670014820a07162857bda94dcc7 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math -ftree-vectorize -msse -mfpmath=sse -mrecip" } */
+/* { dg-options "-O2 -ffast-math -ftree-vectorize -msse -mfpmath=sse -mrecip -fno-common" } */
 
 float a[4];
 float b[4];
index 9ac9bd76ce951131f13b546eeaf1ee600722f524..6c0d49b2214fb13c8867fd30874fedcb28c88814 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math -ftree-vectorize -msse -mfpmath=sse -mrecip" } */
+/* { dg-options "-O2 -ffast-math -ftree-vectorize -msse -mfpmath=sse -mrecip -fno-common" } */
 
 float a[4];
 float b[4];
index b458d624d64264f746c69eb76c60c5c180c0cd94..9b66d86d1247224018583ee2bab13dccdb892414 100644 (file)
@@ -872,10 +872,7 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
 
   if (!base_aligned)
     {
-      /* Do not change the alignment of global variables if
-        flag_section_anchors is enabled.  */
-      if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype))
-         || (TREE_STATIC (base) && flag_section_anchors))
+      if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype)))
        {
          if (vect_print_dump_info (REPORT_DETAILS))
            {
@@ -4546,12 +4543,22 @@ vect_can_force_dr_alignment_p (const_tree decl, unsigned int alignment)
   if (TREE_CODE (decl) != VAR_DECL)
     return false;
 
-  if (DECL_EXTERNAL (decl))
+  /* We cannot change alignment of common or external symbols as another
+     translation unit may contain a definition with lower alignment.  
+     The rules of common symbol linking mean that the definition
+     will override the common symbol.  */
+  if (DECL_EXTERNAL (decl)
+      || DECL_COMMON (decl))
     return false;
 
   if (TREE_ASM_WRITTEN (decl))
     return false;
 
+  /* Do not change the alignment of global variables if flag_section_anchors
+     is enabled.  */
+  if (TREE_STATIC (decl) && flag_section_anchors)
+    return false;
+
   if (TREE_STATIC (decl))
     return (alignment <= MAX_OFILE_ALIGNMENT);
   else