]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/84775 (ICE on valid code at -O3: in check_loop_closed_ssa_def...
authorRichard Biener <rguenther@suse.de>
Fri, 9 Mar 2018 13:29:39 +0000 (13:29 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 9 Mar 2018 13:29:39 +0000 (13:29 +0000)
2018-03-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/84775
* tree-if-conv.c (add_bb_predicate_gimplified_stmts): Delink
immediate uses of predicate stmts and mark them modified.

Revert
PR tree-optimization/84178
* tree-if-conv.c (combine_blocks): Move insert_gimplified_predicates
to caller.
(version_loop_for_if_conversion): Delay update_ssa call.
(tree_if_conversion): Delay update_ssa until after predicate
insertion.

* gcc.dg/torture/pr84775.c: New testcase.

From-SVN: r258387

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr84775.c [new file with mode: 0644]
gcc/tree-if-conv.c

index 69b7def90bf33f75d7396ef2124b483c842c8e6d..5b2f59bfd780c7916c5b92c160ff4068457cdf3e 100644 (file)
@@ -1,3 +1,17 @@
+2018-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84775
+       * tree-if-conv.c (add_bb_predicate_gimplified_stmts): Delink
+       immediate uses of predicate stmts and mark them modified.
+
+       Revert
+       PR tree-optimization/84178
+       * tree-if-conv.c (combine_blocks): Move insert_gimplified_predicates
+       to caller.
+       (version_loop_for_if_conversion): Delay update_ssa call.
+       (tree_if_conversion): Delay update_ssa until after predicate
+       insertion.
+
 2018-03-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR target/84763
index aadf99889524f2670ba69a46ac1eae8218b538c4..de8b13f6598f593abd1f920de3e92a9905da6c59 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84775
+       * gcc.dg/torture/pr84775.c: New testcase.
+
 2018-03-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/84404
diff --git a/gcc/testsuite/gcc.dg/torture/pr84775.c b/gcc/testsuite/gcc.dg/torture/pr84775.c
new file mode 100644 (file)
index 0000000..bb9466b
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int a, b, c, d, e, f;
+
+void fn1 ()
+{
+  while (e)
+    for (f = 0; f < 4; f++)
+      {
+       int h[1];
+       for (; c; c++)
+         if (a)
+           break;
+       d = a - 4;
+       if (d)
+         b = h[0];
+      }
+}
index 59a0f1c887d01072d191d0a629d26e08d0c3252e..c68a0c72d988a79f63c42419e1fb2a6b62c700af 100644 (file)
@@ -257,6 +257,19 @@ set_bb_predicate_gimplified_stmts (basic_block bb, gimple_seq stmts)
 static inline void
 add_bb_predicate_gimplified_stmts (basic_block bb, gimple_seq stmts)
 {
+  /* We might have updated some stmts in STMTS via force_gimple_operand
+     calling fold_stmt and that producing multiple stmts.  Delink immediate
+     uses so update_ssa after loop versioning doesn't get confused for
+     the not yet inserted predicates.
+     ???  This should go away once we reliably avoid updating stmts
+     not in any BB.  */
+  for (gimple_stmt_iterator gsi = gsi_start (stmts);
+       !gsi_end_p (gsi); gsi_next (&gsi))
+    {
+      gimple *stmt = gsi_stmt (gsi);
+      delink_stmt_imm_use (stmt);
+      gimple_set_modified (stmt, true);
+    }
   gimple_seq_add_seq_without_update
     (&(((struct bb_predicate *) bb->aux)->predicate_gimplified_stmts), stmts);
 }
@@ -2371,6 +2384,7 @@ combine_blocks (struct loop *loop)
   edge_iterator ei;
 
   remove_conditions_and_labels (loop);
+  insert_gimplified_predicates (loop);
   predicate_all_scalar_phis (loop);
 
   if (any_pred_load_store)
@@ -2592,6 +2606,7 @@ version_loop_for_if_conversion (struct loop *loop)
   gsi = gsi_last_bb (cond_bb);
   gimple_call_set_arg (g, 1, build_int_cst (integer_type_node, new_loop->num));
   gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+  update_ssa (TODO_update_ssa);
   return new_loop;
 }
 
@@ -2809,7 +2824,6 @@ tree_if_conversion (struct loop *loop)
   unsigned int todo = 0;
   bool aggressive_if_conv;
   struct loop *rloop;
-  bool need_update_ssa = false;
 
  again:
   rloop = NULL;
@@ -2855,7 +2869,6 @@ tree_if_conversion (struct loop *loop)
       struct loop *nloop = version_loop_for_if_conversion (vloop);
       if (nloop == NULL)
        goto cleanup;
-      need_update_ssa = true;
       if (vloop != loop)
        {
          /* If versionable_outer_loop_p decided to version the
@@ -2880,13 +2893,6 @@ tree_if_conversion (struct loop *loop)
        }
     }
 
-  /* Due to hard to fix issues we end up with immediate uses recorded
-     for not yet inserted predicates which will confuse SSA update so
-     we delayed this from after versioning to after predicate insertion.  */
-  insert_gimplified_predicates (loop);
-  if (need_update_ssa)
-    update_ssa (TODO_update_ssa);
-
   /* Now all statements are if-convertible.  Combine all the basic
      blocks into one huge basic block doing the if-conversion
      on-the-fly.  */
This page took 0.091572 seconds and 5 git commands to generate.