re PR middle-end/85594 (ICE during expand when compiling with -fwrapv -fopenmp)
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 Dec 2018 19:17:13 +0000 (20:17 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 21 Dec 2018 19:17:13 +0000 (20:17 +0100)
PR middle-end/85594
PR middle-end/88553
* omp-expand.c (extract_omp_for_update_vars): Regimplify the condition
if needed.
(expand_omp_for_generic): Don't clobber t temporary for ordered loops.

* gcc.dg/gomp/pr85594.c: New test.
* gcc.dg/gomp/pr88553.c: New test.

From-SVN: r267339

gcc/ChangeLog
gcc/omp-expand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr85594.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr88553.c [new file with mode: 0644]

index b8db48863de5a18a85bfbffd64e620b0d3faaa6b..2db37e78c757f07156ca2244d38513a8631d976c 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/85594
+       PR middle-end/88553
+       * omp-expand.c (extract_omp_for_update_vars): Regimplify the condition
+       if needed.
+       (expand_omp_for_generic): Don't clobber t temporary for ordered loops.
+
 2018-12-15  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/88561
index 76c09c5883b758d0348a510a7c49feef9deca03d..b5cb4241508ecd9471a892794f2e6c815b6b7340 100644 (file)
@@ -2076,6 +2076,11 @@ extract_omp_for_update_vars (struct omp_for_data *fd, basic_block cont_bb,
          t = fold_build2 (fd->loops[i].cond_code, boolean_type_node, v, t);
          stmt = gimple_build_cond_empty (t);
          gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+         if (walk_tree (gimple_cond_lhs_ptr (as_a <gcond *> (stmt)),
+                        expand_omp_regimplify_p, NULL, NULL)
+             || walk_tree (gimple_cond_rhs_ptr (as_a <gcond *> (stmt)),
+                           expand_omp_regimplify_p, NULL, NULL))
+           gimple_regimplify_operands (stmt, &gsi);
          e = make_edge (bb, body_bb, EDGE_TRUE_VALUE);
          e->probability = profile_probability::guessed_always ().apply_scale (7, 8);
        }
@@ -3209,20 +3214,21 @@ expand_omp_for_generic (struct omp_region *region,
 
          if (fd->ordered && counts[fd->collapse - 1] == NULL_TREE)
            {
+             tree tem;
              if (fd->collapse > 1)
-               t = fd->loop.v;
+               tem = fd->loop.v;
              else
                {
-                 t = fold_build2 (MINUS_EXPR, TREE_TYPE (fd->loops[0].v),
-                                  fd->loops[0].v, fd->loops[0].n1);
-                 t = fold_convert (fd->iter_type, t);
+                 tem = fold_build2 (MINUS_EXPR, TREE_TYPE (fd->loops[0].v),
+                                    fd->loops[0].v, fd->loops[0].n1);
+                 tem = fold_convert (fd->iter_type, tem);
                }
              tree aref = build4 (ARRAY_REF, fd->iter_type,
                                  counts[fd->ordered], size_zero_node,
                                  NULL_TREE, NULL_TREE);
-             t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
-                                           true, GSI_SAME_STMT);
-             expand_omp_build_assign (&gsi, aref, t);
+             tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE,
+                                             true, GSI_SAME_STMT);
+             expand_omp_build_assign (&gsi, aref, tem);
            }
 
          t = build2 (fd->loop.cond_code, boolean_type_node,
index 0018d8b3394520e0e3466e13372c59c5de8de969..e5928ecec61d14f6ad2002b1f37406da369b7d34 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/85594
+       PR middle-end/88553
+       * gcc.dg/gomp/pr85594.c: New test.
+       * gcc.dg/gomp/pr88553.c: New test.
+
 2018-12-15  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/88561
diff --git a/gcc/testsuite/gcc.dg/gomp/pr85594.c b/gcc/testsuite/gcc.dg/gomp/pr85594.c
new file mode 100644 (file)
index 0000000..5577a33
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR middle-end/85594 */
+/* { dg-do compile } */
+/* { dg-additional-options "-fwrapv" } */
+
+#include "pr81768-2.c"
diff --git a/gcc/testsuite/gcc.dg/gomp/pr88553.c b/gcc/testsuite/gcc.dg/gomp/pr88553.c
new file mode 100644 (file)
index 0000000..6252def
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR middle-end/88553 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O1 -ftree-loop-vectorize -fwrapv" } */
+
+#include "pr81768-2.c"