From: Jakub Jelinek Date: Tue, 5 Sep 2017 21:32:35 +0000 (+0200) Subject: re PR middle-end/81768 (error: control flow in the middle of basic block) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0fe4bc787a5dccb0d22ee3872cfeb5c4663b144b;p=gcc.git re PR middle-end/81768 (error: control flow in the middle of basic block) PR middle-end/81768 * omp-low.c (lower_omp_for): Recompute tree invariant if gimple_omp_for_initial/final is ADDR_EXPR. * gcc.dg/gomp/pr81768-2.c: New test. From-SVN: r251742 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95ecb3cd854..53637905722 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2017-09-05 Jakub Jelinek + PR middle-end/81768 + * omp-low.c (lower_omp_for): Recompute tree invariant if + gimple_omp_for_initial/final is ADDR_EXPR. + PR middle-end/81768 * omp-expand.c (expand_omp_simd): Force second operands of COND_EXPR into gimple val before gimplification fo the COND_EXPR. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 080f2f4a994..8ed8f7c90f2 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -6923,10 +6923,14 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx) rhs_p = gimple_omp_for_initial_ptr (stmt, i); if (!is_gimple_min_invariant (*rhs_p)) *rhs_p = get_formal_tmp_var (*rhs_p, &body); + else if (TREE_CODE (*rhs_p) == ADDR_EXPR) + recompute_tree_invariant_for_addr_expr (*rhs_p); rhs_p = gimple_omp_for_final_ptr (stmt, i); if (!is_gimple_min_invariant (*rhs_p)) *rhs_p = get_formal_tmp_var (*rhs_p, &body); + else if (TREE_CODE (*rhs_p) == ADDR_EXPR) + recompute_tree_invariant_for_addr_expr (*rhs_p); rhs_p = &TREE_OPERAND (gimple_omp_for_incr (stmt, i), 1); if (!is_gimple_min_invariant (*rhs_p)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e470ff150ae..667d1cbcbba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-09-05 Jakub Jelinek + PR middle-end/81768 + * gcc.dg/gomp/pr81768-2.c: New test. + PR middle-end/81768 * gcc.dg/gomp/pr81768-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/gomp/pr81768-2.c b/gcc/testsuite/gcc.dg/gomp/pr81768-2.c new file mode 100644 index 00000000000..64ae66f16ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr81768-2.c @@ -0,0 +1,15 @@ +/* PR middle-end/81768 */ +/* { dg-do compile } */ + +float b[10][15][10]; + +void +foo (void) +{ + float *i; +#pragma omp target parallel for schedule(static, 32) collapse(3) + for (i = &b[0][0][0]; i < &b[0][0][10]; i++) + for (float *j = &b[0][15][0]; j > &b[0][0][0]; j -= 10) + for (float *k = &b[0][0][10]; k > &b[0][0][0]; --k) + b[i - &b[0][0][0]][(j - &b[0][0][0]) / 10 - 1][(k - &b[0][0][0]) - 1] -= 3.5; +}