re PR tree-optimization/71647 (aligned(x:32) in #pragma omp simd does not work)
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Jun 2016 18:44:11 +0000 (20:44 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 24 Jun 2016 18:44:11 +0000 (20:44 +0200)
PR tree-optimization/71647
* omp-low.c (lower_rec_input_clauses): Convert
omp_clause_aligned_alignment (c) to size_type_node for the
last argument of __builtin_assume_aligned.

* gcc.target/i386/pr71647.c: New test.

From-SVN: r237769

gcc/ChangeLog
gcc/omp-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr71647.c [new file with mode: 0644]

index 80048f15a664f194fc8ae0a2e4da84eae382d332..71b818167edac458a4db4292ebd76a8c7d56e91f 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/71647
+       * omp-low.c (lower_rec_input_clauses): Convert
+       omp_clause_aligned_alignment (c) to size_type_node for the
+       last argument of __builtin_assume_aligned.
+
 2016-06-24  Martin Liska  <mliska@suse.cz>
 
        * cfgloop.c (flow_loop_dump): Dump average number of loop iterations.
index 22e59094e82e377d1e62e66c2592989112ac7b7c..b89978f77236edbaeaebdebd6dc4d12d799807d8 100644 (file)
@@ -4475,8 +4475,9 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                  if (new_var == NULL_TREE)
                    new_var = maybe_lookup_decl_in_outer_ctx (var, ctx);
                  x = builtin_decl_explicit (BUILT_IN_ASSUME_ALIGNED);
-                 x = build_call_expr_loc (clause_loc, x, 2, new_var,
-                                          omp_clause_aligned_alignment (c));
+                 tree alarg = omp_clause_aligned_alignment (c);
+                 alarg = fold_convert_loc (clause_loc, size_type_node, alarg);
+                 x = build_call_expr_loc (clause_loc, x, 2, new_var, alarg);
                  x = fold_convert_loc (clause_loc, TREE_TYPE (new_var), x);
                  x = build2 (MODIFY_EXPR, TREE_TYPE (new_var), new_var, x);
                  gimplify_and_add (x, ilist);
@@ -4489,8 +4490,9 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                  t = maybe_lookup_decl_in_outer_ctx (var, ctx);
                  t = build_fold_addr_expr_loc (clause_loc, t);
                  t2 = builtin_decl_explicit (BUILT_IN_ASSUME_ALIGNED);
-                 t = build_call_expr_loc (clause_loc, t2, 2, t,
-                                          omp_clause_aligned_alignment (c));
+                 tree alarg = omp_clause_aligned_alignment (c);
+                 alarg = fold_convert_loc (clause_loc, size_type_node, alarg);
+                 t = build_call_expr_loc (clause_loc, t2, 2, t, alarg);
                  t = fold_convert_loc (clause_loc, ptype, t);
                  x = create_tmp_var (ptype);
                  t = build2 (MODIFY_EXPR, ptype, x, t);
index f85270c0646b9b3955671c23ed55125865f44531..1ec279cf0eb360e0a0eb8009b5710feedef6b380 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/71647
+       * gcc.target/i386/pr71647.c: New test.
+
 2016-06-24  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/vect/vect-nb-iter-ub-1.c: Remove default vector
diff --git a/gcc/testsuite/gcc.target/i386/pr71647.c b/gcc/testsuite/gcc.target/i386/pr71647.c
new file mode 100644 (file)
index 0000000..ab091bd
--- /dev/null
@@ -0,0 +1,32 @@
+/* PR tree-optimization/71647 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fopenmp-simd -mavx -mno-avx512f -fdump-tree-vect-details" } */
+
+void
+foo (double *a, double *b)
+{
+  int i;
+#pragma omp simd aligned(a,b:4*sizeof(double))
+  for (i = 0; i < 32768; i++)
+    a[i] += b[i];
+}
+
+void
+bar (double *a, double *b)
+{
+  int i;
+#pragma omp simd aligned(a,b:32)
+  for (i = 0; i < 32768; i++)
+    a[i] += b[i];
+}
+
+void
+baz (double *a, double *b)
+{
+  int i;
+#pragma omp simd aligned(a,b:32L)
+  for (i = 0; i < 32768; i++)
+    a[i] += b[i];
+}
+
+/* { dg-final { scan-tree-dump-not "Alignment of access forced using peeling" "vect" } } */