f1ba2f4
2013-06-19  Igor Zamyatin  <igor.zamyatin@intel.com>
f1ba2f4
f1ba2f4
	* gcc.dg/tree-ssa/loop-19.c: Add -fno-common.
f1ba2f4
f1ba2f4
2013-06-12  Jakub Jelinek  <jakub@redhat.com>
f1ba2f4
f1ba2f4
	PR target/56564
f1ba2f4
	* varasm.c (decl_binds_to_current_def_p): Call binds_local_p
f1ba2f4
	target hook even for !TREE_PUBLIC decls.  If no resolution info
f1ba2f4
	is available, return false for common and external decls.
f1ba2f4
f1ba2f4
	* gcc.target/i386/pr56564-1.c: Skip on darwin, mingw and cygwin.
f1ba2f4
	* gcc.target/i386/pr56564-3.c: Likewise.
f1ba2f4
f1ba2f4
2013-06-11  Jakub Jelinek  <jakub@redhat.com>
f1ba2f4
f1ba2f4
	PR target/56564
f1ba2f4
	* varasm.c (get_variable_align): Move #endif to the right place.
f1ba2f4
0e0fc28
2013-06-10  Jakub Jelinek  <jakub@redhat.com>
0e0fc28
0e0fc28
	PR target/56564
0e0fc28
	* varasm.c (align_variable): Don't use DATA_ALIGNMENT or
0e0fc28
	CONSTANT_ALIGNMENT if !decl_binds_to_current_def_p (decl).
0e0fc28
	Use DATA_ABI_ALIGNMENT for that case instead if defined.
0e0fc28
	(get_variable_align): New function.
0e0fc28
	(get_variable_section, emit_bss, emit_common,
0e0fc28
	assemble_variable_contents, place_block_symbol): Use
0e0fc28
	get_variable_align instead of DECL_ALIGN.
0e0fc28
	(assemble_noswitch_variable): Add align argument, use it
0e0fc28
	instead of DECL_ALIGN.
0e0fc28
	(assemble_variable): Adjust caller.  Use get_variable_align
0e0fc28
	instead of DECL_ALIGN.
0e0fc28
	* config/i386/i386.h (DATA_ALIGNMENT): Adjust x86_data_alignment
0e0fc28
	caller.
0e0fc28
	(DATA_ABI_ALIGNMENT): Define.
0e0fc28
	* config/i386/i386-protos.h (x86_data_alignment): Adjust prototype.
0e0fc28
	* config/i386/i386.c (x86_data_alignment): Add opt argument.  If
0e0fc28
	opt is false, only return the psABI mandated alignment increase.
0e0fc28
	* config/c6x/c6x.h (DATA_ALIGNMENT): Renamed to...
0e0fc28
	(DATA_ABI_ALIGNMENT): ... this.
0e0fc28
	* config/mmix/mmix.h (DATA_ALIGNMENT): Renamed to...
0e0fc28
	(DATA_ABI_ALIGNMENT): ... this.
0e0fc28
	* config/mmix/mmix.c (mmix_data_alignment): Adjust function comment.
0e0fc28
	* config/s390/s390.h (DATA_ALIGNMENT): Renamed to...
0e0fc28
	(DATA_ABI_ALIGNMENT): ... this.
0e0fc28
	* doc/tm.texi.in (DATA_ABI_ALIGNMENT): Document.
0e0fc28
	* doc/tm.texi: Regenerated.
0e0fc28
0e0fc28
	* gcc.target/i386/pr56564-1.c: New test.
0e0fc28
	* gcc.target/i386/pr56564-2.c: New test.
0e0fc28
	* gcc.target/i386/pr56564-3.c: New test.
0e0fc28
	* gcc.target/i386/pr56564-4.c: New test.
0e0fc28
	* gcc.target/i386/avx256-unaligned-load-4.c: Add -fno-common.
0e0fc28
	* gcc.target/i386/avx256-unaligned-store-1.c: Likewise.
0e0fc28
	* gcc.target/i386/avx256-unaligned-store-3.c: Likewise.
0e0fc28
	* gcc.target/i386/avx256-unaligned-store-4.c: Likewise.
0e0fc28
	* gcc.target/i386/vect-sizes-1.c: Likewise.
0e0fc28
	* gcc.target/i386/memcpy-1.c: Likewise.
0e0fc28
	* gcc.dg/vect/costmodel/i386/costmodel-vect-31.c (tmp): Initialize.
0e0fc28
	* gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c (tmp): Likewise.
0e0fc28
0e0fc28
--- gcc/doc/tm.texi.in	(revision 199897)
0e0fc28
+++ gcc/doc/tm.texi.in	(revision 199898)
0e0fc28
@@ -1062,6 +1062,15 @@ arrays to be word-aligned so that @code{
0e0fc28
 constants to character arrays can be done inline.
0e0fc28
 @end defmac
0e0fc28
 
0e0fc28
+@defmac DATA_ABI_ALIGNMENT (@var{type}, @var{basic-align})
0e0fc28
+Similar to @code{DATA_ALIGNMENT}, but for the cases where the ABI mandates
0e0fc28
+some alignment increase, instead of optimization only purposes.  E.g.@
0e0fc28
+AMD x86-64 psABI says that variables with array type larger than 15 bytes
0e0fc28
+must be aligned to 16 byte boundaries.
0e0fc28
+
0e0fc28
+If this macro is not defined, then @var{basic-align} is used.
0e0fc28
+@end defmac
0e0fc28
+
0e0fc28
 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
0e0fc28
 If defined, a C expression to compute the alignment given to a constant
0e0fc28
 that is being placed in memory.  @var{constant} is the constant and
0e0fc28
--- gcc/doc/tm.texi	(revision 199897)
0e0fc28
+++ gcc/doc/tm.texi	(revision 199898)
0e0fc28
@@ -1078,6 +1078,15 @@ arrays to be word-aligned so that @code{
0e0fc28
 constants to character arrays can be done inline.
0e0fc28
 @end defmac
0e0fc28
 
0e0fc28
+@defmac DATA_ABI_ALIGNMENT (@var{type}, @var{basic-align})
0e0fc28
+Similar to @code{DATA_ALIGNMENT}, but for the cases where the ABI mandates
0e0fc28
+some alignment increase, instead of optimization only purposes.  E.g.@
0e0fc28
+AMD x86-64 psABI says that variables with array type larger than 15 bytes
0e0fc28
+must be aligned to 16 byte boundaries.
0e0fc28
+
0e0fc28
+If this macro is not defined, then @var{basic-align} is used.
0e0fc28
+@end defmac
0e0fc28
+
0e0fc28
 @defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
0e0fc28
 If defined, a C expression to compute the alignment given to a constant
0e0fc28
 that is being placed in memory.  @var{constant} is the constant and
0e0fc28
--- gcc/varasm.c	(revision 199897)
f1ba2f4
+++ gcc/varasm.c	(revision 199984)
0e0fc28
@@ -966,13 +966,80 @@ align_variable (tree decl, bool dont_out
0e0fc28
       align = MAX_OFILE_ALIGNMENT;
0e0fc28
     }
0e0fc28
 
0e0fc28
-  /* On some machines, it is good to increase alignment sometimes.  */
0e0fc28
   if (! DECL_USER_ALIGN (decl))
0e0fc28
     {
0e0fc28
+#ifdef DATA_ABI_ALIGNMENT
0e0fc28
+      unsigned int data_abi_align
0e0fc28
+	= DATA_ABI_ALIGNMENT (TREE_TYPE (decl), align);
0e0fc28
+      /* For backwards compatibility, don't assume the ABI alignment for
0e0fc28
+	 TLS variables.  */
0e0fc28
+      if (! DECL_THREAD_LOCAL_P (decl) || data_abi_align <= BITS_PER_WORD)
0e0fc28
+	align = data_abi_align;
0e0fc28
+#endif
0e0fc28
+
0e0fc28
+      /* On some machines, it is good to increase alignment sometimes.
0e0fc28
+	 But as DECL_ALIGN is used both for actually emitting the variable
0e0fc28
+	 and for code accessing the variable as guaranteed alignment, we
0e0fc28
+	 can only increase the alignment if it is a performance optimization
0e0fc28
+	 if the references to it must bind to the current definition.  */
0e0fc28
+      if (decl_binds_to_current_def_p (decl))
0e0fc28
+	{
0e0fc28
+#ifdef DATA_ALIGNMENT
0e0fc28
+	  unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
0e0fc28
+	  /* Don't increase alignment too much for TLS variables - TLS space
0e0fc28
+	     is too precious.  */
0e0fc28
+	  if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
0e0fc28
+	    align = data_align;
0e0fc28
+#endif
0e0fc28
+#ifdef CONSTANT_ALIGNMENT
0e0fc28
+	  if (DECL_INITIAL (decl) != 0
0e0fc28
+	      && DECL_INITIAL (decl) != error_mark_node)
0e0fc28
+	    {
0e0fc28
+	      unsigned int const_align
0e0fc28
+		= CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
0e0fc28
+	      /* Don't increase alignment too much for TLS variables - TLS
0e0fc28
+		 space is too precious.  */
0e0fc28
+	      if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
0e0fc28
+		align = const_align;
0e0fc28
+	    }
0e0fc28
+#endif
0e0fc28
+	}
0e0fc28
+    }
0e0fc28
+
0e0fc28
+  /* Reset the alignment in case we have made it tighter, so we can benefit
0e0fc28
+     from it in get_pointer_alignment.  */
0e0fc28
+  DECL_ALIGN (decl) = align;
0e0fc28
+}
0e0fc28
+
0e0fc28
+/* Return DECL_ALIGN (decl), possibly increased for optimization purposes
0e0fc28
+   beyond what align_variable returned.  */
0e0fc28
+
0e0fc28
+static unsigned int
0e0fc28
+get_variable_align (tree decl)
0e0fc28
+{
0e0fc28
+  unsigned int align = DECL_ALIGN (decl);
0e0fc28
+
0e0fc28
+  /* For user aligned vars or static vars align_variable already did
0e0fc28
+     everything.  */
0e0fc28
+  if (DECL_USER_ALIGN (decl) || !TREE_PUBLIC (decl))
0e0fc28
+    return align;
0e0fc28
+
0e0fc28
+#ifdef DATA_ABI_ALIGNMENT
0e0fc28
+  if (DECL_THREAD_LOCAL_P (decl))
0e0fc28
+    align = DATA_ABI_ALIGNMENT (TREE_TYPE (decl), align);
0e0fc28
+#endif
0e0fc28
+
0e0fc28
+  /* For decls that bind to the current definition, align_variable
0e0fc28
+     did also everything, except for not assuming ABI required alignment
0e0fc28
+     of TLS variables.  For other vars, increase the alignment here
0e0fc28
+     as an optimization.  */
0e0fc28
+  if (!decl_binds_to_current_def_p (decl))
0e0fc28
+    {
0e0fc28
+      /* On some machines, it is good to increase alignment sometimes.  */
0e0fc28
 #ifdef DATA_ALIGNMENT
0e0fc28
       unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
0e0fc28
       /* Don't increase alignment too much for TLS variables - TLS space
0e0fc28
-	 is too precious.  */
0e0fc28
+         is too precious.  */
0e0fc28
       if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
0e0fc28
 	align = data_align;
0e0fc28
 #endif
f1ba2f4
@@ -989,9 +1056,7 @@ align_variable (tree decl, bool dont_out
f1ba2f4
 #endif
0e0fc28
     }
0e0fc28
 
0e0fc28
-  /* Reset the alignment in case we have made it tighter, so we can benefit
0e0fc28
-     from it in get_pointer_alignment.  */
0e0fc28
-  DECL_ALIGN (decl) = align;
0e0fc28
+  return align;
0e0fc28
 }
0e0fc28
 
0e0fc28
 /* Return the section into which the given VAR_DECL or CONST_DECL
0e0fc28
@@ -1043,7 +1108,8 @@ get_variable_section (tree decl, bool pr
0e0fc28
 	return bss_noswitch_section;
0e0fc28
     }
0e0fc28
 
0e0fc28
-  return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
0e0fc28
+  return targetm.asm_out.select_section (decl, reloc,
0e0fc28
+					 get_variable_align (decl));
0e0fc28
 }
0e0fc28
 
0e0fc28
 /* Return the block into which object_block DECL should be placed.  */
0e0fc28
@@ -1780,7 +1846,8 @@ emit_bss (tree decl ATTRIBUTE_UNUSED,
0e0fc28
 	  unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
0e0fc28
 {
0e0fc28
 #if defined ASM_OUTPUT_ALIGNED_BSS
0e0fc28
-  ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl));
0e0fc28
+  ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size,
0e0fc28
+			  get_variable_align (decl));
0e0fc28
   return true;
0e0fc28
 #endif
0e0fc28
 }
0e0fc28
@@ -1796,10 +1863,11 @@ emit_common (tree decl ATTRIBUTE_UNUSED,
0e0fc28
 {
0e0fc28
 #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
0e0fc28
   ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name,
0e0fc28
-				  size, DECL_ALIGN (decl));
0e0fc28
+				  size, get_variable_align (decl));
0e0fc28
   return true;
0e0fc28
 #elif defined ASM_OUTPUT_ALIGNED_COMMON
0e0fc28
-  ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl));
0e0fc28
+  ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
0e0fc28
+			     get_variable_align (decl));
0e0fc28
   return true;
0e0fc28
 #else
0e0fc28
   ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
0e0fc28
@@ -1828,7 +1896,8 @@ emit_tls_common (tree decl ATTRIBUTE_UNU
0e0fc28
    NAME is the name of DECL's SYMBOL_REF.  */
0e0fc28
 
0e0fc28
 static void
0e0fc28
-assemble_noswitch_variable (tree decl, const char *name, section *sect)
0e0fc28
+assemble_noswitch_variable (tree decl, const char *name, section *sect,
0e0fc28
+			    unsigned int align)
0e0fc28
 {
0e0fc28
   unsigned HOST_WIDE_INT size, rounded;
0e0fc28
 
0e0fc28
@@ -1850,7 +1919,7 @@ assemble_noswitch_variable (tree decl, c
0e0fc28
 	     * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
0e0fc28
 
0e0fc28
   if (!sect->noswitch.callback (decl, name, size, rounded)
0e0fc28
-      && (unsigned HOST_WIDE_INT) DECL_ALIGN_UNIT (decl) > rounded)
0e0fc28
+      && (unsigned HOST_WIDE_INT) (align / BITS_PER_UNIT) > rounded)
0e0fc28
     warning (0, "requested alignment for %q+D is greater than "
0e0fc28
 	     "implemented alignment of %wu", decl, rounded);
0e0fc28
 }
0e0fc28
@@ -1880,7 +1949,7 @@ assemble_variable_contents (tree decl, c
0e0fc28
 	/* Output the actual data.  */
0e0fc28
 	output_constant (DECL_INITIAL (decl),
0e0fc28
 			 tree_low_cst (DECL_SIZE_UNIT (decl), 1),
0e0fc28
-			 DECL_ALIGN (decl));
0e0fc28
+			 get_variable_align (decl));
0e0fc28
       else
0e0fc28
 	/* Leave space for it.  */
0e0fc28
 	assemble_zeros (tree_low_cst (DECL_SIZE_UNIT (decl), 1));
0e0fc28
@@ -1904,6 +1973,7 @@ assemble_variable (tree decl, int top_le
0e0fc28
   const char *name;
0e0fc28
   rtx decl_rtl, symbol;
0e0fc28
   section *sect;
0e0fc28
+  unsigned int align;
0e0fc28
   bool asan_protected = false;
0e0fc28
 
0e0fc28
   /* This function is supposed to handle VARIABLES.  Ensure we have one.  */
0e0fc28
@@ -2003,6 +2073,8 @@ assemble_variable (tree decl, int top_le
0e0fc28
 
0e0fc28
   set_mem_align (decl_rtl, DECL_ALIGN (decl));
0e0fc28
 
0e0fc28
+  align = get_variable_align (decl);
0e0fc28
+
0e0fc28
   if (TREE_PUBLIC (decl))
0e0fc28
     maybe_assemble_visibility (decl);
0e0fc28
 
0e0fc28
@@ -2032,12 +2104,12 @@ assemble_variable (tree decl, int top_le
0e0fc28
       place_block_symbol (symbol);
0e0fc28
     }
0e0fc28
   else if (SECTION_STYLE (sect) == SECTION_NOSWITCH)
0e0fc28
-    assemble_noswitch_variable (decl, name, sect);
0e0fc28
+    assemble_noswitch_variable (decl, name, sect, align);
0e0fc28
   else
0e0fc28
     {
0e0fc28
       switch_to_section (sect);
0e0fc28
-      if (DECL_ALIGN (decl) > BITS_PER_UNIT)
0e0fc28
-	ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DECL_ALIGN_UNIT (decl)));
0e0fc28
+      if (align > BITS_PER_UNIT)
0e0fc28
+	ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
0e0fc28
       assemble_variable_contents (decl, name, dont_output_data);
0e0fc28
       if (asan_protected)
0e0fc28
 	{
f1ba2f4
@@ -6709,10 +6781,10 @@ bool
f1ba2f4
 decl_binds_to_current_def_p (tree decl)
f1ba2f4
 {
f1ba2f4
   gcc_assert (DECL_P (decl));
f1ba2f4
-  if (!TREE_PUBLIC (decl))
f1ba2f4
-    return true;
f1ba2f4
   if (!targetm.binds_local_p (decl))
f1ba2f4
     return false;
f1ba2f4
+  if (!TREE_PUBLIC (decl))
f1ba2f4
+    return true;
f1ba2f4
   /* When resolution is available, just use it.  */
f1ba2f4
   if (TREE_CODE (decl) == VAR_DECL
f1ba2f4
       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
f1ba2f4
@@ -6730,10 +6802,20 @@ decl_binds_to_current_def_p (tree decl)
f1ba2f4
 	return resolution_to_local_definition_p (node->symbol.resolution);
f1ba2f4
     }
f1ba2f4
   /* Otherwise we have to assume the worst for DECL_WEAK (hidden weaks
f1ba2f4
-     binds locally but still can be overwritten).
f1ba2f4
+     binds locally but still can be overwritten), DECL_COMMON (can be merged
f1ba2f4
+     with a non-common definition somewhere in the same module) or
f1ba2f4
+     DECL_EXTERNAL.
f1ba2f4
      This rely on fact that binds_local_p behave as decl_replaceable_p
f1ba2f4
      for all other declaration types.  */
f1ba2f4
-  return !DECL_WEAK (decl);
f1ba2f4
+  if (DECL_WEAK (decl))
f1ba2f4
+    return false;
f1ba2f4
+  if (DECL_COMMON (decl)
f1ba2f4
+      && (DECL_INITIAL (decl) == NULL
f1ba2f4
+	  || DECL_INITIAL (decl) == error_mark_node))
f1ba2f4
+    return false;
f1ba2f4
+  if (DECL_EXTERNAL (decl))
f1ba2f4
+    return false;
f1ba2f4
+  return true;
f1ba2f4
 }
f1ba2f4
 
f1ba2f4
 /* A replaceable function or variable is one which may be replaced
f1ba2f4
@@ -6959,7 +7041,7 @@ place_block_symbol (rtx symbol)
0e0fc28
   else
0e0fc28
     {
0e0fc28
       decl = SYMBOL_REF_DECL (symbol);
0e0fc28
-      alignment = DECL_ALIGN (decl);
0e0fc28
+      alignment = get_variable_align (decl);
0e0fc28
       size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);
0e0fc28
       if (flag_asan && asan_protect_global (decl))
0e0fc28
 	{
0e0fc28
--- gcc/config/s390/s390.h	(revision 199897)
0e0fc28
+++ gcc/config/s390/s390.h	(revision 199898)
0e0fc28
@@ -221,7 +221,7 @@ enum processor_flags
0e0fc28
 
0e0fc28
 /* Alignment on even addresses for LARL instruction.  */
0e0fc28
 #define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
0e0fc28
-#define DATA_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
0e0fc28
+#define DATA_ABI_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
0e0fc28
 
0e0fc28
 /* Alignment is not required by the hardware.  */
0e0fc28
 #define STRICT_ALIGNMENT 0
0e0fc28
--- gcc/config/i386/i386.h	(revision 199897)
0e0fc28
+++ gcc/config/i386/i386.h	(revision 199898)
0e0fc28
@@ -859,7 +859,18 @@ enum target_cpu_default
0e0fc28
    cause character arrays to be word-aligned so that `strcpy' calls
0e0fc28
    that copy constants to character arrays can be done inline.  */
0e0fc28
 
0e0fc28
-#define DATA_ALIGNMENT(TYPE, ALIGN) ix86_data_alignment ((TYPE), (ALIGN))
0e0fc28
+#define DATA_ALIGNMENT(TYPE, ALIGN) \
0e0fc28
+  ix86_data_alignment ((TYPE), (ALIGN), true)
0e0fc28
+
0e0fc28
+/* Similar to DATA_ALIGNMENT, but for the cases where the ABI mandates
0e0fc28
+   some alignment increase, instead of optimization only purposes.  E.g.
0e0fc28
+   AMD x86-64 psABI says that variables with array type larger than 15 bytes
0e0fc28
+   must be aligned to 16 byte boundaries.
0e0fc28
+
0e0fc28
+   If this macro is not defined, then ALIGN is used.  */
0e0fc28
+
0e0fc28
+#define DATA_ABI_ALIGNMENT(TYPE, ALIGN) \
0e0fc28
+  ix86_data_alignment ((TYPE), (ALIGN), false)
0e0fc28
 
0e0fc28
 /* If defined, a C expression to compute the alignment for a local
0e0fc28
    variable.  TYPE is the data type, and ALIGN is the alignment that
0e0fc28
--- gcc/config/i386/i386-protos.h	(revision 199897)
0e0fc28
+++ gcc/config/i386/i386-protos.h	(revision 199898)
0e0fc28
@@ -207,7 +207,7 @@ extern void init_cumulative_args (CUMULA
0e0fc28
 #endif	/* RTX_CODE  */
0e0fc28
 
0e0fc28
 #ifdef TREE_CODE
0e0fc28
-extern int ix86_data_alignment (tree, int);
0e0fc28
+extern int ix86_data_alignment (tree, int, bool);
0e0fc28
 extern unsigned int ix86_local_alignment (tree, enum machine_mode,
0e0fc28
 					  unsigned int);
0e0fc28
 extern unsigned int ix86_minimum_alignment (tree, enum machine_mode,
0e0fc28
--- gcc/config/i386/i386.c	(revision 199897)
0e0fc28
+++ gcc/config/i386/i386.c	(revision 199898)
0e0fc28
@@ -25375,11 +25375,12 @@ ix86_constant_alignment (tree exp, int a
0e0fc28
    instead of that alignment to align the object.  */
0e0fc28
 
0e0fc28
 int
0e0fc28
-ix86_data_alignment (tree type, int align)
0e0fc28
+ix86_data_alignment (tree type, int align, bool opt)
0e0fc28
 {
0e0fc28
   int max_align = optimize_size ? BITS_PER_WORD : MIN (256, MAX_OFILE_ALIGNMENT);
0e0fc28
 
0e0fc28
-  if (AGGREGATE_TYPE_P (type)
0e0fc28
+  if (opt
0e0fc28
+      && AGGREGATE_TYPE_P (type)
0e0fc28
       && TYPE_SIZE (type)
0e0fc28
       && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
0e0fc28
       && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= (unsigned) max_align
0e0fc28
@@ -25391,14 +25392,17 @@ ix86_data_alignment (tree type, int alig
0e0fc28
      to 16byte boundary.  */
0e0fc28
   if (TARGET_64BIT)
0e0fc28
     {
0e0fc28
-      if (AGGREGATE_TYPE_P (type)
0e0fc28
-	   && TYPE_SIZE (type)
0e0fc28
-	   && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
0e0fc28
-	   && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 128
0e0fc28
-	       || TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 128)
0e0fc28
+      if ((opt ? AGGREGATE_TYPE_P (type) : TREE_CODE (type) == ARRAY_TYPE)
0e0fc28
+	  && TYPE_SIZE (type)
0e0fc28
+	  && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
0e0fc28
+	  && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 128
0e0fc28
+	      || TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 128)
0e0fc28
 	return 128;
0e0fc28
     }
0e0fc28
 
0e0fc28
+  if (!opt)
0e0fc28
+    return align;
0e0fc28
+
0e0fc28
   if (TREE_CODE (type) == ARRAY_TYPE)
0e0fc28
     {
0e0fc28
       if (TYPE_MODE (TREE_TYPE (type)) == DFmode && align < 64)
0e0fc28
--- gcc/config/c6x/c6x.h	(revision 199897)
0e0fc28
+++ gcc/config/c6x/c6x.h	(revision 199898)
0e0fc28
@@ -134,7 +134,7 @@ extern c6x_cpu_t c6x_arch;
0e0fc28
    Really only externally visible arrays must be aligned this way, as
0e0fc28
    only those are directly visible from another compilation unit.  But
0e0fc28
    we don't have that information available here.  */
0e0fc28
-#define DATA_ALIGNMENT(TYPE, ALIGN)					\
0e0fc28
+#define DATA_ABI_ALIGNMENT(TYPE, ALIGN)					\
0e0fc28
   (((ALIGN) < BITS_PER_UNIT * 8 && TREE_CODE (TYPE) == ARRAY_TYPE)	\
0e0fc28
    ? BITS_PER_UNIT * 8 : (ALIGN))
0e0fc28
 
0e0fc28
--- gcc/config/mmix/mmix.h	(revision 199897)
0e0fc28
+++ gcc/config/mmix/mmix.h	(revision 199898)
0e0fc28
@@ -164,7 +164,7 @@ struct GTY(()) machine_function
0e0fc28
 /* Copied from elfos.h.  */
0e0fc28
 #define MAX_OFILE_ALIGNMENT (32768 * 8)
0e0fc28
 
0e0fc28
-#define DATA_ALIGNMENT(TYPE, BASIC_ALIGN) \
0e0fc28
+#define DATA_ABI_ALIGNMENT(TYPE, BASIC_ALIGN) \
0e0fc28
  mmix_data_alignment (TYPE, BASIC_ALIGN)
0e0fc28
 
0e0fc28
 #define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \
0e0fc28
--- gcc/config/mmix/mmix.c	(revision 199897)
0e0fc28
+++ gcc/config/mmix/mmix.c	(revision 199898)
0e0fc28
@@ -313,7 +313,7 @@ mmix_init_machine_status (void)
0e0fc28
   return ggc_alloc_cleared_machine_function ();
0e0fc28
 }
0e0fc28
 
0e0fc28
-/* DATA_ALIGNMENT.
0e0fc28
+/* DATA_ABI_ALIGNMENT.
0e0fc28
    We have trouble getting the address of stuff that is located at other
0e0fc28
    than 32-bit alignments (GETA requirements), so try to give everything
0e0fc28
    at least 32-bit alignment.  */
0e0fc28
--- gcc/testsuite/gcc.target/i386/memcpy-1.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/memcpy-1.c	(revision 199898)
0e0fc28
@@ -1,6 +1,6 @@
0e0fc28
 /* { dg-do compile } */
0e0fc28
 /* { dg-require-effective-target ia32 } */
0e0fc28
-/* { dg-options "-O2 -march=pentiumpro -minline-all-stringops" } */
0e0fc28
+/* { dg-options "-O2 -march=pentiumpro -minline-all-stringops -fno-common" } */
0e0fc28
 /* { dg-final { scan-assembler "rep" } } */
0e0fc28
 /* { dg-final { scan-assembler "movs" } } */
0e0fc28
 /* { dg-final { scan-assembler-not "test" } } */
0e0fc28
--- gcc/testsuite/gcc.target/i386/vect-sizes-1.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/vect-sizes-1.c	(revision 199898)
0e0fc28
@@ -1,5 +1,5 @@
0e0fc28
 /* { dg-do compile } */
0e0fc28
-/* { dg-options "-O3 -ffast-math -mavx -mtune=generic" } */
0e0fc28
+/* { dg-options "-O3 -ffast-math -mavx -mtune=generic -fno-common" } */
0e0fc28
 
0e0fc28
 double a[1024];
0e0fc28
 
0e0fc28
--- gcc/testsuite/gcc.target/i386/avx256-unaligned-load-4.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/avx256-unaligned-load-4.c	(revision 199898)
0e0fc28
@@ -1,5 +1,5 @@
0e0fc28
 /* { dg-do compile } */
0e0fc28
-/* { dg-options "-O3 -dp -mavx -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store" } */
0e0fc28
+/* { dg-options "-O3 -dp -mavx -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store -fno-common" } */
0e0fc28
 
0e0fc28
 #define N 1024
0e0fc28
 
0e0fc28
--- gcc/testsuite/gcc.target/i386/avx256-unaligned-store-1.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/avx256-unaligned-store-1.c	(revision 199898)
0e0fc28
@@ -1,5 +1,5 @@
0e0fc28
 /* { dg-do compile } */
0e0fc28
-/* { dg-options "-O3 -dp -mavx -mavx256-split-unaligned-store" } */
0e0fc28
+/* { dg-options "-O3 -dp -mavx -mavx256-split-unaligned-store -fno-common" } */
0e0fc28
 
0e0fc28
 #define N 1024
0e0fc28
 
0e0fc28
--- gcc/testsuite/gcc.target/i386/avx256-unaligned-store-3.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/avx256-unaligned-store-3.c	(revision 199898)
0e0fc28
@@ -1,5 +1,5 @@
0e0fc28
 /* { dg-do compile } */
0e0fc28
-/* { dg-options "-O3 -dp -mavx -mavx256-split-unaligned-store -mtune=generic" } */
0e0fc28
+/* { dg-options "-O3 -dp -mavx -mavx256-split-unaligned-store -mtune=generic -fno-common" } */
0e0fc28
 
0e0fc28
 #define N 1024
0e0fc28
 
0e0fc28
--- gcc/testsuite/gcc.target/i386/avx256-unaligned-store-4.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/avx256-unaligned-store-4.c	(revision 199898)
0e0fc28
@@ -1,5 +1,5 @@
0e0fc28
 /* { dg-do compile } */
0e0fc28
-/* { dg-options "-O3 -dp -mavx -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store" } */
0e0fc28
+/* { dg-options "-O3 -dp -mavx -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store -fno-common" } */
0e0fc28
 
0e0fc28
 #define N 1024
0e0fc28
 
0e0fc28
--- gcc/testsuite/gcc.target/i386/pr56564-1.c	(revision 0)
f1ba2f4
+++ gcc/testsuite/gcc.target/i386/pr56564-1.c	(revision 199985)
f1ba2f4
@@ -0,0 +1,26 @@
0e0fc28
+/* PR target/56564 */
0e0fc28
+/* { dg-do compile { target { fpic && lp64 } } } */
f1ba2f4
+/* { dg-skip-if "No symbol interposition for PIC" { *-*-mingw* *-*-cygwin* *-*-darwin* } } */
0e0fc28
+/* { dg-options "-O3 -fpic -fdump-tree-optimized" } */
0e0fc28
+
0e0fc28
+struct S { long a, b; } s = { 5, 6 };
0e0fc28
+char t[16] = { 7 };
0e0fc28
+
0e0fc28
+int
0e0fc28
+foo (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &s) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+int
0e0fc28
+bar (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &t[0]) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+/* { dg-final { scan-tree-dump-times "&s" 1 "optimized" } } */
0e0fc28
+/* { dg-final { scan-tree-dump-times "&t" 0 "optimized" } } */
0e0fc28
+/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */
0e0fc28
+/* { dg-final { scan-assembler ".align\[ \t]*16\[^:]*\[\n\r]s:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { scan-assembler ".align\[ \t]*16\[^:]*\[\n\r]t:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { cleanup-tree-dump "optimized" } } */
0e0fc28
--- gcc/testsuite/gcc.target/i386/pr56564-2.c	(revision 0)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/pr56564-2.c	(revision 199898)
0e0fc28
@@ -0,0 +1,25 @@
0e0fc28
+/* PR target/56564 */
0e0fc28
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
0e0fc28
+/* { dg-options "-O3 -fno-pic -fdump-tree-optimized" } */
0e0fc28
+
0e0fc28
+struct S { long a, b; } s = { 5, 6 };
0e0fc28
+char t[16] = { 7 };
0e0fc28
+
0e0fc28
+int
0e0fc28
+foo (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &s) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+int
0e0fc28
+bar (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &t[0]) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+/* { dg-final { scan-tree-dump-times "&s" 0 "optimized" } } */
0e0fc28
+/* { dg-final { scan-tree-dump-times "&t" 0 "optimized" } } */
0e0fc28
+/* { dg-final { scan-tree-dump-times "return 0" 2 "optimized" } } */
0e0fc28
+/* { dg-final { scan-assembler ".align\[ \t]*16\[^:]*\[\n\r]s:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { scan-assembler ".align\[ \t]*16\[^:]*\[\n\r]t:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { cleanup-tree-dump "optimized" } } */
0e0fc28
--- gcc/testsuite/gcc.target/i386/pr56564-3.c	(revision 0)
f1ba2f4
+++ gcc/testsuite/gcc.target/i386/pr56564-3.c	(revision 199985)
f1ba2f4
@@ -0,0 +1,29 @@
0e0fc28
+/* PR target/56564 */
0e0fc28
+/* { dg-do compile { target { fpic && lp64 } } } */
f1ba2f4
+/* { dg-skip-if "No symbol interposition for PIC" { *-*-mingw* *-*-cygwin* *-*-darwin* } } */
0e0fc28
+/* { dg-options "-O3 -fpic -fdump-tree-optimized" } */
0e0fc28
+
0e0fc28
+__thread struct S { long a, b; } s = { 5, 6 };
0e0fc28
+__thread char t[16] = { 7 };
0e0fc28
+
0e0fc28
+int
0e0fc28
+foo (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &s) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+/* For backwards compatibility we don't assume that t must
0e0fc28
+   be aligned to 16 bytes, but align it anyway.  */
0e0fc28
+
0e0fc28
+int
0e0fc28
+bar (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &t[0]) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+/* { dg-final { scan-tree-dump-times "&s" 1 "optimized" } } */
0e0fc28
+/* { dg-final { scan-tree-dump-times "&t" 1 "optimized" } } */
0e0fc28
+/* { dg-final { scan-tree-dump-times "return 0" 0 "optimized" } } */
0e0fc28
+/* { dg-final { scan-assembler-not ".align\[ \t]*16\[^:]*\[\n\r]s:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { scan-assembler ".align\[ \t]*16\[^:]*\[\n\r]t:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { cleanup-tree-dump "optimized" } } */
0e0fc28
--- gcc/testsuite/gcc.target/i386/pr56564-4.c	(revision 0)
0e0fc28
+++ gcc/testsuite/gcc.target/i386/pr56564-4.c	(revision 199898)
0e0fc28
@@ -0,0 +1,22 @@
0e0fc28
+/* PR target/56564 */
0e0fc28
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
0e0fc28
+/* { dg-options "-O3 -fno-pic -fdump-tree-optimized" } */
0e0fc28
+
0e0fc28
+__thread struct S { long a, b; } s = { 5, 6 };
0e0fc28
+__thread char t[16] = { 7 };
0e0fc28
+
0e0fc28
+int
0e0fc28
+foo (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &s) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+int
0e0fc28
+bar (void)
0e0fc28
+{
0e0fc28
+  return ((__UINTPTR_TYPE__) &t[0]) & 15;
0e0fc28
+}
0e0fc28
+
0e0fc28
+/* { dg-final { scan-assembler-not ".align\[ \t]*16\[^:]*\[\n\r]s:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { scan-assembler ".align\[ \t]*16\[^:]*\[\n\r]t:" { target { *-*-linux* } } } } */
0e0fc28
+/* { dg-final { cleanup-tree-dump "optimized" } } */
0e0fc28
--- gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c	(revision 199898)
0e0fc28
@@ -18,7 +18,7 @@ struct s{
0e0fc28
   struct t e;   /* unaligned (offset 2N+4N+4 B) */
0e0fc28
 };
0e0fc28
  
0e0fc28
-struct s tmp;
0e0fc28
+struct s tmp = { 1 };
0e0fc28
 
0e0fc28
 int main1 ()
0e0fc28
 {  
0e0fc28
--- gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c	(revision 199897)
0e0fc28
+++ gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c	(revision 199898)
0e0fc28
@@ -18,7 +18,7 @@ struct s{
0e0fc28
   struct t e;   /* unaligned (offset 2N+4N+4 B) */
0e0fc28
 };
0e0fc28
  
0e0fc28
-struct s tmp;
0e0fc28
+struct s tmp = { 1 };
0e0fc28
 
0e0fc28
 int main1 ()
0e0fc28
 {  
f1ba2f4
--- gcc/testsuite/gcc.dg/tree-ssa/loop-19.c	(revision 200212)
f1ba2f4
+++ gcc/testsuite/gcc.dg/tree-ssa/loop-19.c	(revision 200213)
f1ba2f4
@@ -6,7 +6,7 @@
f1ba2f4
 
f1ba2f4
 /* { dg-do compile { target { i?86-*-* || { x86_64-*-* || powerpc_hard_double } } } } */
f1ba2f4
 /* { dg-require-effective-target nonpic } */
f1ba2f4
-/* { dg-options "-O3 -fno-tree-loop-distribute-patterns -fno-prefetch-loop-arrays -fdump-tree-optimized" } */
f1ba2f4
+/* { dg-options "-O3 -fno-tree-loop-distribute-patterns -fno-prefetch-loop-arrays -fdump-tree-optimized -fno-common" } */
f1ba2f4
 
f1ba2f4
 # define N      2000000
f1ba2f4
 double   a[N],c[N];