Update stack alignment when increasing local variable alignment.
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 17 Sep 2010 17:49:30 +0000 (17:49 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Fri, 17 Sep 2010 17:49:30 +0000 (10:49 -0700)
gcc/

2010-09-17  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/45678
* cfgexpand.c (update_stack_alignment): New.
(get_decl_align_unit): Use it.
(expand_one_stack_var_at): Call update_stack_alignment.

gcc/testsuite/

2010-09-17  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/45678
* gcc.dg/torture/pr45678-2.c: New.

From-SVN: r164375

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr45678-2.c [new file with mode: 0644]

index a900bdad98dbeed2b41bd80a904c24aac8e9f650..3d2d3775beed29e7752710ad4f1e439b2f8938e6 100644 (file)
@@ -1,3 +1,10 @@
+2010-09-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/45678
+       * cfgexpand.c (update_stack_alignment): New.
+       (get_decl_align_unit): Use it.
+       (expand_one_stack_var_at): Call update_stack_alignment.
+
 2010-09-17  Richard Guenther  <rguenther@suse.de>
 
        * lto-streamer-in.c (lto_input_ts_translation_unit_decl_tree_pointers):
index 42372769049a6113535882d8832de878a3d16eed..1e67e7789789dfc9fd83445d4d1c4cf02861f56f 100644 (file)
@@ -205,19 +205,11 @@ static bool has_protected_decls;
    smaller than our cutoff threshold.  Used for -Wstack-protector.  */
 static bool has_short_buffer;
 
-/* Discover the byte alignment to use for DECL.  Ignore alignment
-   we can't do with expected alignment of the stack boundary.  */
+/* Update stack alignment requirement.  */
 
-static unsigned int
-get_decl_align_unit (tree decl)
+static void
+update_stack_alignment (unsigned int align)
 {
-  unsigned int align;
-
-  align = LOCAL_DECL_ALIGNMENT (decl);
-
-  if (align > MAX_SUPPORTED_STACK_ALIGNMENT)
-    align = MAX_SUPPORTED_STACK_ALIGNMENT;
-
   if (SUPPORTS_STACK_ALIGNMENT)
     {
       if (crtl->stack_alignment_estimated < align)
@@ -233,6 +225,22 @@ get_decl_align_unit (tree decl)
     crtl->stack_alignment_needed = align;
   if (crtl->max_used_stack_slot_alignment < align)
     crtl->max_used_stack_slot_alignment = align;
+}
+
+/* Discover the byte alignment to use for DECL.  Ignore alignment
+   we can't do with expected alignment of the stack boundary.  */
+
+static unsigned int
+get_decl_align_unit (tree decl)
+{
+  unsigned int align;
+
+  align = LOCAL_DECL_ALIGNMENT (decl);
+
+  if (align > MAX_SUPPORTED_STACK_ALIGNMENT)
+    align = MAX_SUPPORTED_STACK_ALIGNMENT;
+
+  update_stack_alignment (align);
 
   return align / BITS_PER_UNIT;
 }
@@ -735,6 +743,7 @@ expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset)
       if (align == 0 || align > max_align)
        align = max_align;
 
+      update_stack_alignment (align);
       DECL_ALIGN (decl) = align;
       DECL_USER_ALIGN (decl) = 0;
     }
index e31952dc98c1e7966cb1b197899d846d28471ee4..1552fa1bb9ad47fe555b6c40d5f5d819a01e963c 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/45678
+       * gcc.dg/torture/pr45678-2.c: New.
+
 2010-09-17  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/45678
diff --git a/gcc/testsuite/gcc.dg/torture/pr45678-2.c b/gcc/testsuite/gcc.dg/torture/pr45678-2.c
new file mode 100644 (file)
index 0000000..449404c
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+typedef float V __attribute__ ((vector_size (16)));
+V g;
+
+int
+main ()
+{
+  float d[4] = { 4, 3, 2, 1 };
+  V e;
+  __builtin_memcpy (&e, &d, sizeof (d));
+  V f = { 5, 15, 25, 35 };
+  e = e * f;
+  g = e;
+  return 0;
+}