From: Jakub Jelinek Date: Tue, 9 Oct 2018 12:53:16 +0000 (+0200) Subject: omp-low.c (lower_omp_task_reductions): Force TYPE_MAX_VALUE into a temporary in the... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fddf42a344b5b96b475635d0bf41cb9ef3a1d65a;p=thirdparty%2Fgcc.git omp-low.c (lower_omp_task_reductions): Force TYPE_MAX_VALUE into a temporary in the start sequence and even when... * 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 --- diff --git a/gcc/ChangeLog.gomp b/gcc/ChangeLog.gomp index 854da5e4647d..a5d5e389e1ee 100644 --- a/gcc/ChangeLog.gomp +++ b/gcc/ChangeLog.gomp @@ -1,3 +1,13 @@ +2018-10-09 Jakub Jelinek + + * 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 * omp-low.c (lower_omp_task_reductions): For array section reductions, diff --git a/gcc/gimplify.c b/gcc/gimplify.c index cfd89401729d..2d86539bbef8 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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 diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 8acffdb9bc29..292dad611eeb 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -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); diff --git a/libgomp/ChangeLog.gomp b/libgomp/ChangeLog.gomp index 555f5a08bc3e..08f2aadd4d53 100644 --- a/libgomp/ChangeLog.gomp +++ b/libgomp/ChangeLog.gomp @@ -1,3 +1,8 @@ +2018-10-09 Jakub Jelinek + + * 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 * task.c (GOMP_taskgroup_reduction_register): If team is NULL, create diff --git a/libgomp/testsuite/libgomp.c-c++-common/task-reduction-5.c b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-5.c index 52880ec6f369..f3e28cc696a6 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/task-reduction-5.c +++ b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-5.c @@ -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; }