From 059673f857885e06d1ca0f50e05dca9387fd4592 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 7 Dec 2010 20:01:36 +0100 Subject: [PATCH] backport: re PR fortran/46753 (ICE: OpenMP - in extract_omp_for_data, at omp-low.c:335) Backport from mainline 2010-12-02 Jakub Jelinek PR fortran/46753 * trans-openmp.c (gfc_trans_omp_do): Use build2_loc instead of fold_build2_loc for OMP_FOR conditions. * libgomp.fortran/pr46753.f90: New test. From-SVN: r167561 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/trans-openmp.c | 10 ++++++---- libgomp/ChangeLog | 3 +++ libgomp/testsuite/libgomp.fortran/pr46753.f90 | 17 +++++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 libgomp/testsuite/libgomp.fortran/pr46753.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6c064431a1f3..01d88fc84bde 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2010-12-07 Jakub Jelinek + + Backport from mainline + 2010-12-02 Jakub Jelinek + + PR fortran/46753 + * trans-openmp.c (gfc_trans_omp_do): Use build2_loc instead of + fold_build2_loc for OMP_FOR conditions. + 2010-11-25 Tobias Burnus PR fortran/46638 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index de24f0fcd307..8248e45a0d2c 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -1240,8 +1240,9 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, if (simple) { TREE_VEC_ELT (init, i) = build2_v (MODIFY_EXPR, dovar, from); - TREE_VEC_ELT (cond, i) = fold_build2 (simple > 0 ? LE_EXPR : GE_EXPR, - boolean_type_node, dovar, to); + /* The condition should not be folded. */ + TREE_VEC_ELT (cond, i) = build2 (simple > 0 ? LE_EXPR : GE_EXPR, + boolean_type_node, dovar, to); TREE_VEC_ELT (incr, i) = fold_build2 (PLUS_EXPR, type, dovar, step); TREE_VEC_ELT (incr, i) = fold_build2 (MODIFY_EXPR, type, dovar, TREE_VEC_ELT (incr, i)); @@ -1262,8 +1263,9 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, count = gfc_create_var (type, "count"); TREE_VEC_ELT (init, i) = build2_v (MODIFY_EXPR, count, build_int_cst (type, 0)); - TREE_VEC_ELT (cond, i) = fold_build2 (LT_EXPR, boolean_type_node, - count, tmp); + /* The condition should not be folded. */ + TREE_VEC_ELT (cond, i) = build2 (LT_EXPR, boolean_type_node, + count, tmp); TREE_VEC_ELT (incr, i) = fold_build2 (PLUS_EXPR, type, count, build_int_cst (type, 1)); TREE_VEC_ELT (incr, i) = fold_build2 (MODIFY_EXPR, type, diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index fbe141a4dd40..10c882b2e1fa 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -3,6 +3,9 @@ Backport from mainline 2010-12-02 Jakub Jelinek + PR fortran/46753 + * libgomp.fortran/pr46753.f90: New test. + PR libgomp/45240 * parallel.c (GOMP_parallel_end): Unlock gomp_remaining_threads_lock at the end if sync builtins aren't supported. diff --git a/libgomp/testsuite/libgomp.fortran/pr46753.f90 b/libgomp/testsuite/libgomp.fortran/pr46753.f90 new file mode 100644 index 000000000000..f4833abc845c --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pr46753.f90 @@ -0,0 +1,17 @@ +! PR fortran/46753 +! { dg-do run } + + integer :: i, j + j = 0 +!$omp parallel do reduction(+:j) + do i = 2147483636, 2147483646 + j = j + 1 + end do + if (j.ne.11) call abort + j = 0 +!$omp parallel do reduction(+:j) + do i = -2147483637, -2147483647, -1 + j = j + 1 + end do + if (j.ne.11) call abort +end -- 2.47.2