Hi!

When a VAR_DECL is copied (e.g. for OpenMP/OpenACC privatization, or
when moving SESE region to another function), copy_var_decl only preserves
user alignment on types, but not on decls.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-01-05  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/68960
        * gimple-expr.c (copy_var_decl): If var has DECL_USER_ALIGN set, copy
        it and DECL_ALIGN too.

        * testsuite/libgomp.c/pr68960.c: New test.

--- gcc/gimple-expr.c.jj        2016-01-04 14:55:52.000000000 +0100
+++ gcc/gimple-expr.c   2016-01-05 16:21:53.831077722 +0100
@@ -375,6 +375,11 @@ copy_var_decl (tree var, tree name, tree
   TREE_USED (copy) = 1;
   DECL_SEEN_IN_BIND_EXPR_P (copy) = 1;
   DECL_ATTRIBUTES (copy) = DECL_ATTRIBUTES (var);
+  if (DECL_USER_ALIGN (var))
+    {
+      DECL_ALIGN (copy) = DECL_ALIGN (var);
+      DECL_USER_ALIGN (copy) = 1;
+    }
 
   return copy;
 }
--- libgomp/testsuite/libgomp.c/pr68960.c.jj    2016-01-05 16:26:34.957162544 
+0100
+++ libgomp/testsuite/libgomp.c/pr68960.c       2016-01-05 16:30:11.000000000 
+0100
@@ -0,0 +1,25 @@
+/* PR middle-end/68960 */
+/* { dg-do run } */
+
+int
+main ()
+{
+  int temp[257] __attribute__ ((aligned (256))) = { 0 };
+  #pragma omp parallel private (temp) num_threads (2)
+  {
+    int *p = &temp[0];
+    asm volatile ("" : "+g" (p));
+    if (((__UINTPTR_TYPE__) p) & 255)
+      __builtin_abort ();
+  }
+  #pragma omp parallel num_threads (2)
+  #pragma omp single
+  #pragma omp task firstprivate (temp)
+  {
+    int *p = &temp[0];
+    asm volatile ("" : "+g" (p));
+    if (((__UINTPTR_TYPE__) p) & 255)
+      __builtin_abort ();
+  }
+  return 0;
+}

        Jakub

Reply via email to