Hi!

The following testcase got broken when we started to test compatibility
of argument types of builtins - the fact that omp-low.c emitted
e.g. int or various other types for the last argument of
the BUILT_IN_ASSUME_ALIGNED builtin now causes it to be ignored.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk and 6.2.

2016-06-24  Jakub Jelinek  <ja...@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.

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

--- gcc/omp-low.c.jj    2016-06-10 20:23:58.000000000 +0200
+++ gcc/omp-low.c       2016-06-24 18:53:01.592784232 +0200
@@ -4475,8 +4475,9 @@ lower_rec_input_clauses (tree clauses, g
                  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, g
                  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);
--- gcc/testsuite/gcc.target/i386/pr71647.c.jj  2016-06-24 19:00:14.805850545 
+0200
+++ gcc/testsuite/gcc.target/i386/pr71647.c     2016-06-24 19:03:21.819722808 
+0200
@@ -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" } } */

        Jakub

Reply via email to