re PR tree-optimization/64284 (ICE: Segmentation fault)
authorRichard Biener <rguenther@suse.de>
Mon, 15 Dec 2014 08:19:55 +0000 (08:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 15 Dec 2014 08:19:55 +0000 (08:19 +0000)
2014-12-15  Richard Biener  <rguenther@suse.de>

PR tree-optimization/64284
* tree-ssa-threadupdate.c (duplicate_seme_region): Mark
the loop for removal if we copied the loop header.

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

From-SVN: r218733

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr64284.c [new file with mode: 0644]
gcc/tree-ssa-threadupdate.c

index 431b2a13537ff26373af496c57381bff388b9f9f..2e0ca74784d8cb09b0db2273f4913211cf5863cb 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64284
+       * tree-ssa-threadupdate.c (duplicate_seme_region): Mark
+       the loop for removal if we copied the loop header.
+
 2014-12-14  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa.c (process_references): Fix conditoinal on flag_optimize
index 1b51abe23d9b535075b127ebf6cb42b46a89bf12..2e21868effba8d18f838aaabe155959ecedb30f8 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64284
+       * gcc.dg/torture/pr64284.c: New testcase.
+
 2014-12-14  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/61602
diff --git a/gcc/testsuite/gcc.dg/torture/pr64284.c b/gcc/testsuite/gcc.dg/torture/pr64284.c
new file mode 100644 (file)
index 0000000..4254381
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+int *a;
+int b;
+int
+fn1() {
+    enum { QSTRING } c = 0;
+    while (1) {
+       switch (*a) {
+         case '\'':
+         c = 0;
+         default:
+         switch (c)
+         case 0:
+           if (b)
+             return 0;
+           c = 1;
+       }
+       a++;
+    }
+}
index 12f83ba64af2c6679d29aedc91c1fc2514d7864e..c7a476af0cfcf77c8eea1444d633c75746c43013 100644 (file)
@@ -2364,7 +2364,7 @@ duplicate_seme_region (edge entry, edge exit,
                       basic_block *region_copy)
 {
   unsigned i;
-  bool free_region_copy = false, copying_header = false;
+  bool free_region_copy = false;
   struct loop *loop = entry->dest->loop_father;
   edge exit_copy;
   edge redirected;
@@ -2388,10 +2388,7 @@ duplicate_seme_region (edge entry, edge exit,
 
   initialize_original_copy_tables ();
 
-  if (copying_header)
-    set_loop_copy (loop, loop_outer (loop));
-  else
-    set_loop_copy (loop, loop);
+  set_loop_copy (loop, loop);
 
   if (!region_copy)
     {
@@ -2453,6 +2450,8 @@ duplicate_seme_region (edge entry, edge exit,
   }
 
   /* Redirect the entry and add the phi node arguments.  */
+  if (entry->dest == loop->header)
+    mark_loop_for_removal (loop);
   redirected = redirect_edge_and_branch (entry, get_bb_copy (entry->dest));
   gcc_assert (redirected != NULL);
   flush_pending_stmts (entry);