]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
omp-low.c (lower_omp_task_reductions): Force TYPE_MAX_VALUE into a temporary in the...
authorJakub Jelinek <jakub@redhat.com>
Tue, 9 Oct 2018 12:53:16 +0000 (14:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 9 Oct 2018 12:53:16 +0000 (14:53 +0200)
* omp-low.c (lower_omp_task_reductions): Force TYPE_MAX_VALUE into
a temporary in the start sequence and even when it is a decl already.

* omp-low.c (lower_rec_input_clauses, lower_reduction_clauses,
lower_omp_task_reductions): Remove second argument create_tmp_var
if it is NULL.
* gimplify.c (gimplify_omp_depend): Likewise.

* testsuite/libgomp.c-c++-common/task-reduction-5.c: Add further test
to verify the array bound var can be changed in taskgroup.

From-SVN: r264957

gcc/ChangeLog.gomp
gcc/gimplify.c
gcc/omp-low.c
libgomp/ChangeLog.gomp
libgomp/testsuite/libgomp.c-c++-common/task-reduction-5.c

index 854da5e4647d5fc4d2e45be1bb437c2340b84a98..a5d5e389e1eec819641e3810376a8fb9bc459eaa 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-09  Jakub Jelinek  <jakub@redhat.com>
+
+       * omp-low.c (lower_omp_task_reductions): Force TYPE_MAX_VALUE into
+       a temporary in the start sequence and even when it is a decl already.
+
+       * omp-low.c (lower_rec_input_clauses, lower_reduction_clauses,
+       lower_omp_task_reductions): Remove second argument create_tmp_var
+       if it is NULL.
+       * gimplify.c (gimplify_omp_depend): Likewise.
+
 2018-10-08  Jakub Jelinek  <jakub@redhat.com>
 
        * omp-low.c (lower_omp_task_reductions): For array section reductions,
index cfd89401729de251ef8a30552f430d707ae3111e..2d86539bbef8daeafcdab82841d2ba6399281696 100644 (file)
@@ -7736,7 +7736,7 @@ gimplify_omp_depend (tree *list_p, gimple_seq *pre_p)
          cnts[i] = cnts[i - 1];
          continue;
        }
-      cnts[i] = create_tmp_var (sizetype, NULL);
+      cnts[i] = create_tmp_var (sizetype);
       if (i == 0)
        g = gimple_build_assign (cnts[i], size_int (is_old ? 2 : 5));
       else
index 8acffdb9bc2930597b74493a8a4c9de58eb614f6..292dad611eebe888c11886972be7de0b422c43aa 100644 (file)
@@ -4091,7 +4091,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                  gimple_seq_add_stmt (ilist, g);
                }
 
-             tree y1 = create_tmp_var (ptype, NULL);
+             tree y1 = create_tmp_var (ptype);
              gimplify_assign (y1, y, ilist);
              tree i2 = NULL_TREE, y2 = NULL_TREE;
              tree body2 = NULL_TREE, end2 = NULL_TREE;
@@ -4102,14 +4102,14 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                                     size_int (task_reduction_cnt_full
                                               + task_reduction_cntorig - 1),
                                     NULL_TREE, NULL_TREE);
-                 y3 = create_tmp_var (ptype, NULL);
+                 y3 = create_tmp_var (ptype);
                  gimplify_assign (y3, ref, ilist);
                }
              else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) || is_simd)
                {
                  if (pass != 3)
                    {
-                     y2 = create_tmp_var (ptype, NULL);
+                     y2 = create_tmp_var (ptype);
                      gimplify_assign (y2, y, ilist);
                    }
                  if (is_simd || OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c))
@@ -4126,23 +4126,23 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
                      if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)
                          && OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c))
                        {
-                         y3 = create_tmp_var (ptype, NULL);
+                         y3 = create_tmp_var (ptype);
                          gimplify_assign (y3, unshare_expr (ref), ilist);
                        }
                      if (is_simd)
                        {
-                         y4 = create_tmp_var (ptype, NULL);
+                         y4 = create_tmp_var (ptype);
                          gimplify_assign (y4, ref, dlist);
                        }
                    }
                }
-             tree i = create_tmp_var (TREE_TYPE (v), NULL);
+             tree i = create_tmp_var (TREE_TYPE (v));
              gimplify_assign (i, build_int_cst (TREE_TYPE (v), 0), ilist);
              tree body = create_artificial_label (UNKNOWN_LOCATION);
              gimple_seq_add_stmt (ilist, gimple_build_label (body));
              if (y2)
                {
-                 i2 = create_tmp_var (TREE_TYPE (v), NULL);
+                 i2 = create_tmp_var (TREE_TYPE (v));
                  gimplify_assign (i2, build_int_cst (TREE_TYPE (v), 0), dlist);
                  body2 = create_artificial_label (UNKNOWN_LOCATION);
                  end2 = create_artificial_label (UNKNOWN_LOCATION);
@@ -5603,7 +5603,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx)
          tree d = OMP_CLAUSE_DECL (c);
          tree type = TREE_TYPE (d);
          tree v = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
-         tree i = create_tmp_var (TREE_TYPE (v), NULL);
+         tree i = create_tmp_var (TREE_TYPE (v));
          tree ptype = build_pointer_type (TREE_TYPE (type));
          tree bias = TREE_OPERAND (d, 1);
          d = TREE_OPERAND (d, 0);
@@ -5667,10 +5667,10 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx)
            }
          new_var = fold_convert_loc (clause_loc, ptype, new_var);
          ref = fold_convert_loc (clause_loc, ptype, ref);
-         tree m = create_tmp_var (ptype, NULL);
+         tree m = create_tmp_var (ptype);
          gimplify_assign (m, new_var, stmt_seqp);
          new_var = m;
-         m = create_tmp_var (ptype, NULL);
+         m = create_tmp_var (ptype);
          gimplify_assign (m, ref, stmt_seqp);
          ref = m;
          gimplify_assign (i, build_int_cst (TREE_TYPE (v), 0), stmt_seqp);
@@ -6896,22 +6896,24 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses,
            {
              tree type = TREE_TYPE (new_var);
              tree v = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
-             tree i = create_tmp_var (TREE_TYPE (v), NULL);
+             tree i = create_tmp_var (TREE_TYPE (v));
              tree ptype = build_pointer_type (TREE_TYPE (type));
              if (DECL_P (v))
                {
                  v = maybe_lookup_decl_in_outer_ctx (v, ctx);
-                 gimplify_expr (&v, end, NULL, is_gimple_val, fb_rvalue);
+                 tree vv = create_tmp_var (TREE_TYPE (v));
+                 gimplify_assign (vv, v, start);
+                 v = vv;
                }
              ref = build4 (ARRAY_REF, pointer_sized_int_node, avar,
                            size_int (7 + cnt * 3), NULL_TREE, NULL_TREE);
              new_var = build_fold_addr_expr (new_var);
              new_var = fold_convert (ptype, new_var);
              ref = fold_convert (ptype, ref);
-             tree m = create_tmp_var (ptype, NULL);
+             tree m = create_tmp_var (ptype);
              gimplify_assign (m, new_var, end);
              new_var = m;
-             m = create_tmp_var (ptype, NULL);
+             m = create_tmp_var (ptype);
              gimplify_assign (m, ref, end);
              ref = m;
              gimplify_assign (i, build_int_cst (TREE_TYPE (v), 0), end);
index 555f5a08bc3e064f1752754c0182692615ddb530..08f2aadd4d53e2b8dd6d4be13532a93d3b93d97c 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-09  Jakub Jelinek  <jakub@redhat.com>
+
+       * testsuite/libgomp.c-c++-common/task-reduction-5.c: Add further test
+       to verify the array bound var can be changed in taskgroup.
+
 2018-10-08  Jakub Jelinek  <jakub@redhat.com>
 
        * task.c (GOMP_taskgroup_reduction_register): If team is NULL, create
index 52880ec6f369157555fe922ff4e618d230fc6932..f3e28cc696a65a91cfffbd3f031f54790c674f58 100644 (file)
@@ -7,49 +7,58 @@ void abort (void);
 int *q;
 
 void
-bar (int *p, int *r, int s)
+bar (int *p, int *r, int *t, int s, __SIZE_TYPE__ u)
 {
-  #pragma omp task in_reduction (*: p[0], q[0], r[s - 1])
+  #pragma omp task in_reduction (*: p[0], q[0], r[s - 1], t[0:u + 1])
   {
     *p *= 4;
     *q *= 5;
     r[s - 1] *= 6;
+    t[0] *= 8;
+    t[1] *= 9;
   }
 }
 
 void
-foo (int *p, int *r, int s)
+foo (int *p, int *r, int *t, int s, __SIZE_TYPE__ u)
 {
   int *p2 = p;
-  #pragma omp taskgroup task_reduction (*: p[0], q[0], r[s])
+  #pragma omp taskgroup task_reduction (*: p[0], q[0], r[s], t[0:u + 1])
   {
     p = (int *) 0;
     s++;
-    bar (p2, r, s);
+    bar (p2, r, t, s, u);
     r++;
     #pragma omp taskwait
-    #pragma omp task in_reduction (*: p2[0], q[0], r[s - 2])
+    #pragma omp task in_reduction (*: p2[0], q[0], r[s - 2], t[0:u + 1])
     {
       *p2 *= 2;
       *q *= 3;
       r[s - 2] *= 7;
+      t[0] *= 10;
+      t[1] *= 11;
     }
+    u = __SIZE_MAX__ / 4;
     s++;
     p2 = (int *) 0;
     q = (int *) 0;
     r = (int *) 0;
+    t = (int *) 0;
   }
 }
 
 int
 main ()
 {
-  int a = 1, b = 1, c[2] = { 1, 0 };
+  int a = 1, b = 1, c[2] = { 1, 0 }, d[3] = { 1, 1, -1 };
+  volatile int zero;
+  zero = 0;
   q = &b;
   #pragma omp parallel num_threads (2)
   #pragma omp master
-  foo (&a, &c[0], 0);
-  if (a != 8 || b != 15 || c[0] != 42 || c[1] != 0)
+  foo (&a, &c[0], &d[0], zero, zero + 1);
+  if (a != 8 || b != 15 || c[0] != 42 || c[1] != 0
+      || d[0] != 80 || d[1] != 99 || d[2] != -1)
     abort ();
   return 0;
 }