spot / rpms / cross-gcc

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