backport: re PR middle-end/81768 (error: control flow in the middle of basic block)

Backported from mainline
	2017-09-05  Jakub Jelinek  <jakub@redhat.com>

	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: r251857
This commit is contained in:
Jakub Jelinek 2017-09-07 22:41:42 +02:00 committed by Jakub Jelinek
parent 22bfd3f3a9
commit f0da73ec40
4 changed files with 26 additions and 0 deletions

View File

@ -3,6 +3,10 @@
Backported from mainline
2017-09-05 Jakub Jelinek <jakub@redhat.com>
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.

View File

@ -6927,10 +6927,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))

View File

@ -3,6 +3,9 @@
Backported from mainline
2017-09-05 Jakub Jelinek <jakub@redhat.com>
PR middle-end/81768
* gcc.dg/gomp/pr81768-2.c: New test.
PR middle-end/81768
* gcc.dg/gomp/pr81768-1.c: New test.

View File

@ -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;
}