This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix OpenMP lowering related ICE (PR middle-end/81768)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 5 Sep 2017 23:39:05 +0200
- Subject: [committed] Fix OpenMP lowering related ICE (PR middle-end/81768)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B81B17266E
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
On the following testcase we ICE because during OpenMP lowering we failed
to recompute ADDR_EXPR invariants after a VAR_DECL has been replaced by a
target mapping. Normally this is done in lower_omp_regimplify_p, but
the OMP_FOR initial/final trees don't go through that.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed so far to trunk.
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.
--- gcc/omp-low.c.jj 2017-09-01 09:25:46.000000000 +0200
+++ gcc/omp-low.c 2017-09-05 15:07:10.086125109 +0200
@@ -6923,10 +6923,14 @@ lower_omp_for (gimple_stmt_iterator *gsi
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))
--- gcc/testsuite/gcc.dg/gomp/pr81768-2.c.jj 2017-09-05 15:08:15.989343325 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr81768-2.c 2017-09-05 14:25:43.000000000 +0200
@@ -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;
+}
Jakub