From 0fe4bc787a5dccb0d22ee3872cfeb5c4663b144b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 5 Sep 2017 23:32:35 +0200 Subject: [PATCH] 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 --- gcc/ChangeLog | 4 ++++ gcc/omp-low.c | 4 ++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/gomp/pr81768-2.c | 15 +++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/gomp/pr81768-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95ecb3c..5363790 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,10 @@ 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 080f2f4..8ed8f7c 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 e470ff1..667d1cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,9 @@ 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. 2017-09-05 Bill Schmidt 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 0000000..64ae66f --- /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; +} -- 2.7.4