re PR tree-optimization/82563 ([graphite] ICE in check_loop_closed_ssa_def, at tree...
authorRichard Biener <rguenther@suse.de>
Tue, 17 Oct 2017 13:17:30 +0000 (13:17 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 17 Oct 2017 13:17:30 +0000 (13:17 +0000)
2017-10-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82563
* graphite-isl-ast-to-gimple.c (generate_entry_out_of_ssa_copies):
New function.
(graphite_regenerate_ast_isl): Call it.
* graphite-scop-detection.c (build_scops): Remove entry edge split.

* gcc.dg/graphite/pr82563.c: New testcase.

From-SVN: r253809

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c
gcc/graphite-scop-detection.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr82563.c [new file with mode: 0644]

index 63688adf67970b13763d60aacea614e5817426d8..4107557527283ced69e67df3d4181ef749992865 100644 (file)
@@ -1,3 +1,11 @@
+2017-10-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82563
+       * graphite-isl-ast-to-gimple.c (generate_entry_out_of_ssa_copies):
+       New function.
+       (graphite_regenerate_ast_isl): Call it.
+       * graphite-scop-detection.c (build_scops): Remove entry edge split.
+
 2017-10-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/82549
index 2a583aba63bd5ebdb25fec324325dd92fc8d7ee3..959d31dbb2c59c909b3d9dd3556c261023c21398 100644 (file)
@@ -1501,6 +1501,35 @@ copy_internal_parameters (sese_info_p region, sese_info_p to_region)
     }
 }
 
+/* Generate out-of-SSA copies for the entry edge FALSE_ENTRY/TRUE_ENTRY
+   in REGION.  */
+
+static void
+generate_entry_out_of_ssa_copies (edge false_entry,
+                                 edge true_entry,
+                                 sese_info_p region)
+{
+  gimple_stmt_iterator gsi_tgt = gsi_start_bb (true_entry->dest);
+  for (gphi_iterator psi = gsi_start_phis (false_entry->dest);
+       !gsi_end_p (psi); gsi_next (&psi))
+    {
+      gphi *phi = psi.phi ();
+      tree res = gimple_phi_result (phi);
+      if (virtual_operand_p (res))
+       continue;
+      /* When there's no out-of-SSA var registered do not bother
+         to create one.  */
+      vec <tree> *renames = region->rename_map->get (res);
+      if (! renames || renames->is_empty ())
+       continue;
+      tree new_phi_def = (*renames)[0];
+      gassign *ass = gimple_build_assign (new_phi_def,
+                                         PHI_ARG_DEF_FROM_EDGE (phi,
+                                                                false_entry));
+      gsi_insert_after (&gsi_tgt, ass, GSI_NEW_STMT);
+    }
+}
+
 /* GIMPLE Loop Generator: generates loops in GIMPLE form for the given SCOP.
    Return true if code generation succeeded.  */
 
@@ -1548,6 +1577,9 @@ graphite_regenerate_ast_isl (scop_p scop)
   t.translate_isl_ast (context_loop, root_node, e, ip);
   if (! t.codegen_error_p ())
     {
+      generate_entry_out_of_ssa_copies (if_region->false_region->region.entry,
+                                       if_region->true_region->region.entry,
+                                       region);
       sese_insert_phis_for_liveouts (region,
                                     if_region->region->region.exit->src,
                                     if_region->false_region->region.exit,
index c7e1dba9423a177b5e1806391112c7a0ada9d79a..ce6ab9545275061afffaa78938328855dc532aae 100644 (file)
@@ -1708,10 +1708,6 @@ build_scops (vec<scop_p> *scops)
   sese_l *s;
   FOR_EACH_VEC_ELT (scops_l, i, s)
     {
-      /* For our out-of-SSA we need a block on s->entry, similar to how
-         we include the LCSSA block in the region.  */
-      s->entry = single_pred_edge (split_edge (s->entry));
-
       scop_p scop = new_scop (s->entry, s->exit);
 
       /* Record all basic blocks and their conditions in REGION.  */
index 1a692d3859e6c425d21584f723e698448afcdc53..bd817f7c0c6b7f7bbf70678ffc4f9df32bcd5ea8 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82563
+       * gcc.dg/graphite/pr82563.c: New testcase.
+
 2017-10-17  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/67831
diff --git a/gcc/testsuite/gcc.dg/graphite/pr82563.c b/gcc/testsuite/gcc.dg/graphite/pr82563.c
new file mode 100644 (file)
index 0000000..cd492fa
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -floop-nest-optimize" } */
+
+int tj, cw, xf;
+
+void
+zp (int *ei)
+{
+  for (;;)
+    {
+      int hd = 0;
+
+      if (cw != 0 && xf != 0)
+       {
+         for (hd = 0; hd < 3; ++hd)
+           cw = (tj != 0) ? 0 : *ei;
+         for (;;)
+           ;
+       }
+
+      while (tj != 0)
+       tj = (__UINTPTR_TYPE__)&hd;
+    }
+}