diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-11-25 21:28:56 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2009-11-25 21:28:56 +0100 |
commit | 281e33e1bb62f77b7f999213da93db0088d08e1d (patch) | |
tree | e09f0b243a46a3ff9e7a5acdd73e3b23f01bee52 | |
parent | fc07d9e3cb53293002fde46afb834aa965bab195 (diff) | |
download | gcc-281e33e1bb62f77b7f999213da93db0088d08e1d.zip gcc-281e33e1bb62f77b7f999213da93db0088d08e1d.tar.gz gcc-281e33e1bb62f77b7f999213da93db0088d08e1d.tar.bz2 |
re PR fortran/42162 (OpenMP: ICE: tree check in omp_add_variable, at gimplify.c:5282)
PR fortran/42162
* trans-openmp.c (gfc_trans_omp_do): When dovar isn't a VAR_DECL,
don't use simple loop and handle clauses properly.
* testsuite/libgomp.fortran/pr42162.f90: New test.
From-SVN: r154654
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-openmp.c | 24 | ||||
-rw-r--r-- | libgomp/ChangeLog | 7 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/pr42162.f90 | 53 |
4 files changed, 81 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0b38750..2ca0e24 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-11-25 Jakub Jelinek <jakub@redhat.com> + + PR fortran/42162 + * trans-openmp.c (gfc_trans_omp_do): When dovar isn't a VAR_DECL, + don't use simple loop and handle clauses properly. + 2009-11-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/42008 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 4d461cf..7343d1a 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -1160,6 +1160,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, { int simple = 0; int dovar_found = 0; + tree dovar_decl; if (clauses) { @@ -1200,12 +1201,19 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, gfc_conv_expr_val (&se, code->ext.iterator->step); gfc_add_block_to_block (pblock, &se.pre); step = gfc_evaluate_now (se.expr, pblock); + dovar_decl = dovar; /* Special case simple loops. */ - if (integer_onep (step)) - simple = 1; - else if (tree_int_cst_equal (step, integer_minus_one_node)) - simple = -1; + if (TREE_CODE (dovar) == VAR_DECL) + { + if (integer_onep (step)) + simple = 1; + else if (tree_int_cst_equal (step, integer_minus_one_node)) + simple = -1; + } + else + dovar_decl + = gfc_trans_omp_variable (code->ext.iterator->var->symtree->n.sym); /* Loop body. */ if (simple) @@ -1249,7 +1257,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, if (!dovar_found) { tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); - OMP_CLAUSE_DECL (tmp) = dovar; + OMP_CLAUSE_DECL (tmp) = dovar_decl; omp_clauses = gfc_trans_add_clause (tmp, omp_clauses); } else if (dovar_found == 2) @@ -1269,7 +1277,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, tmp = fold_build2 (MODIFY_EXPR, type, dovar, tmp); for (c = omp_clauses; c ; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE - && OMP_CLAUSE_DECL (c) == dovar) + && OMP_CLAUSE_DECL (c) == dovar_decl) { OMP_CLAUSE_LASTPRIVATE_STMT (c) = tmp; break; @@ -1279,11 +1287,11 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, { for (c = par_clauses; c ; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE - && OMP_CLAUSE_DECL (c) == dovar) + && OMP_CLAUSE_DECL (c) == dovar_decl) { tree l = build_omp_clause (input_location, OMP_CLAUSE_LASTPRIVATE); - OMP_CLAUSE_DECL (l) = dovar; + OMP_CLAUSE_DECL (l) = dovar_decl; OMP_CLAUSE_CHAIN (l) = omp_clauses; OMP_CLAUSE_LASTPRIVATE_STMT (l) = tmp; omp_clauses = l; diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index e36c7e2..070d82f 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,7 +1,12 @@ +2009-11-25 Jakub Jelinek <jakub@redhat.com> + + PR fortran/42162 + * testsuite/libgomp.fortran/pr42162.f90: New test. + 2009-11-13 Jakub Jelinek <jakub@redhat.com> PR middle-end/42029 - * libgomp.c/pr42029.c: New test. + * testsuite/libgomp.c/pr42029.c: New test. 2009-10-26 Jakub Jelinek <jakub@redhat.com> diff --git a/libgomp/testsuite/libgomp.fortran/pr42162.f90 b/libgomp/testsuite/libgomp.fortran/pr42162.f90 new file mode 100644 index 0000000..dbcc3b7 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pr42162.f90 @@ -0,0 +1,53 @@ +! PR fortran/42162 +! { dg-do run } + +subroutine sub1(k, a) + implicit none + integer :: k, a(3) + !$omp do + do k=1,3 + a(k) = a(k) + 1 + enddo + !$omp end do +end subroutine sub1 + +subroutine sub2(k, a) + implicit none + integer :: k, a(3) + !$omp do private (k) + do k=1,3 + a(k) = a(k) + 1 + enddo + !$omp end do +end subroutine sub2 + +subroutine sub3(k, a) + implicit none + integer :: k, a(3) + !$omp do lastprivate (k) + do k=1,3 + a(k) = a(k) + 1 + enddo + !$omp end do +end subroutine sub3 + +program pr42162 + implicit none + integer :: k, a(3), b(3), c(3) + a = 1 + b = 2 + c = 3 + k = 3 + !$omp parallel num_threads(3) + call sub1 (k, a) + !$omp end parallel + k = 4 + !$omp parallel num_threads(3) + call sub2 (k, b) + !$omp end parallel + k = 10 + !$omp parallel num_threads(3) + call sub3 (k, c) + !$omp end parallel + if (k.ne.4.or.any(a.ne.2).or.any(b.ne.3).or.any(c.ne.4)) call abort +end |