]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/81768 (error: control flow in the middle of basic block)
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Sep 2017 21:38:43 +0000 (23:38 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 15 Sep 2017 21:38:43 +0000 (23:38 +0200)
Backported from mainline
2017-09-05  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/81768
* omp-low.c (expand_omp_simd): Force second operands of COND_EXPR
into gimple val before gimplification fo the COND_EXPR.

* gcc.dg/gomp/pr81768-1.c: New test.

From-SVN: r252860

gcc/ChangeLog
gcc/omp-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr81768-1.c [new file with mode: 0644]

index be577a0da0cf91f2573b50a9770b4bda4b6f8391..4913dd0dddc303c5e24d38818eb79db9ae3ddf2d 100644 (file)
@@ -1,6 +1,12 @@
 2017-09-15  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-09-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/81768
+       * omp-low.c (expand_omp_simd): Force second operands of COND_EXPR
+       into gimple val before gimplification fo the COND_EXPR.
+
        2017-09-04  Jakub Jelinek  <jakub@redhat.com>
 
        * lra-remat.c (reg_overlap_for_remat_p): Fix a pasto.
index cfc85329c5627e790900ab90d8cea19b6afd26c2..3bff0ac575fb72789cd9235769dc252ad15b7374 100644 (file)
@@ -10653,24 +10653,28 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
              tree itype2 = TREE_TYPE (fd->loops[i - 1].v);
              if (POINTER_TYPE_P (itype2))
                itype2 = signed_type_for (itype2);
+             t = fold_convert (itype2, fd->loops[i - 1].step);
+             t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true,
+                                           GSI_SAME_STMT);
              t = build3 (COND_EXPR, itype2,
                          build2 (fd->loops[i].cond_code, boolean_type_node,
                                  fd->loops[i].v,
                                  fold_convert (itype, fd->loops[i].n2)),
-                         build_int_cst (itype2, 0),
-                         fold_convert (itype2, fd->loops[i - 1].step));
+                         build_int_cst (itype2, 0), t);
              if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i - 1].v)))
                t = fold_build_pointer_plus (fd->loops[i - 1].v, t);
              else
                t = fold_build2 (PLUS_EXPR, itype2, fd->loops[i - 1].v, t);
              expand_omp_build_assign (&gsi, fd->loops[i - 1].v, t);
 
+             t = fold_convert (itype, fd->loops[i].n1);
+             t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true,
+                                           GSI_SAME_STMT);
              t = build3 (COND_EXPR, itype,
                          build2 (fd->loops[i].cond_code, boolean_type_node,
                                  fd->loops[i].v,
                                  fold_convert (itype, fd->loops[i].n2)),
-                         fd->loops[i].v,
-                         fold_convert (itype, fd->loops[i].n1));
+                         fd->loops[i].v, t);
              expand_omp_build_assign (&gsi, fd->loops[i].v, t);
            }
        }
index c09f62469138a58a8e4f1c01d5a76a234043b523..6c0d28746e9aca7b50a96950ddf7dd039b671c95 100644 (file)
@@ -1,6 +1,11 @@
 2017-09-15  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-09-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/81768
+       * gcc.dg/gomp/pr81768-1.c: New test.
+
        2017-08-08  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/81766
diff --git a/gcc/testsuite/gcc.dg/gomp/pr81768-1.c b/gcc/testsuite/gcc.dg/gomp/pr81768-1.c
new file mode 100644 (file)
index 0000000..3b8c26a
--- /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 simd 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;
+}