re PR middle-end/81768 (error: control flow in the middle of basic block)
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Sep 2017 21:32:35 +0000 (23:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Sep 2017 21:32:35 +0000 (23:32 +0200)
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
gcc/omp-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr81768-2.c [new file with mode: 0644]

index 95ecb3cd8544b24071ab0abc847d64554407a0a2..53637905722e128151331decc2b02b7310c7d2a3 100644 (file)
@@ -1,5 +1,9 @@
 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.
index 080f2f4a9941f716a24f5538111bb7da57ee29df..8ed8f7c90f2dd5c2262e3a234710d03aad401a6f 100644 (file)
@@ -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))
index e470ff150ae3cb3d0104ea78ad319c9653eb1e7f..667d1cbcbba49cfacfa78f8b546cc8d626dd3c67 100644 (file)
@@ -1,5 +1,8 @@
 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.
 
diff --git a/gcc/testsuite/gcc.dg/gomp/pr81768-2.c b/gcc/testsuite/gcc.dg/gomp/pr81768-2.c
new file mode 100644 (file)
index 0000000..64ae66f
--- /dev/null
@@ -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;
+}