]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/58551
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Sep 2013 13:44:10 +0000 (13:44 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Sep 2013 13:44:10 +0000 (13:44 +0000)
* tree-cfg.c (move_sese_region_to_fn): Also move loops that
are children of outermost saved_cfun's loop, and set it up to
be moved to dest_cfun's outermost loop.  Fix up num_nodes adjustments
if loop != loop0 and SESE region contains bbs that belong to loop0.

* c-c++-common/gomp/pr58551.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202972 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr58551.c [new file with mode: 0644]
gcc/tree-cfg.c

index 4f40aadc96634ce1b95af7a69d4d1c6de9466dff..620229e3b3bd874b0efeef37cd406a4e2ed278a5 100644 (file)
@@ -1,3 +1,11 @@
+2013-09-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/58551
+       * tree-cfg.c (move_sese_region_to_fn): Also move loops that
+       are children of outermost saved_cfun's loop, and set it up to
+       be moved to dest_cfun's outermost loop.  Fix up num_nodes adjustments
+       if loop != loop0 and SESE region contains bbs that belong to loop0.
+
 2013-09-27  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * rtlanal.c (must_be_base_p, must_be_index_p): Delete.
index 094fafc35a7ca862101a34b04ac8188e8ed64ea9..2696aa2ea85e1f8488259a94a24d0ad2c3dc44f9 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/58551
+       * c-c++-common/gomp/pr58551.c: New test.
+
 2013-09-27  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/58459
diff --git a/gcc/testsuite/c-c++-common/gomp/pr58551.c b/gcc/testsuite/c-c++-common/gomp/pr58551.c
new file mode 100644 (file)
index 0000000..e2db70f
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR middle-end/58551 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -fopenmp" } */
+
+void
+foo (int *a)
+{
+  int i;
+  for (i = 0; i < 8; i++)
+    #pragma omp task
+    if (a[i])
+      __builtin_abort ();
+}
+
+void bar (int, int);
+
+void
+baz (int *a)
+{
+  int i;
+  for (i = 0; i < 8; i++)
+    #pragma omp task
+    if (a[i])
+      {
+       int j, k;
+       for (j = 0; j < 10; j++)
+         for (k = 0; k < 8; k++)
+           bar (j, k);
+       for (k = 0; k < 12; k++)
+         bar (-1, k);
+       __builtin_abort ();
+      }
+}
index 70930a3592a6ad81296567907f0e96487daec584..d1a6c31c27d526295066ce92bafa7fb6f112fee6 100644 (file)
@@ -6662,12 +6662,13 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
   struct function *saved_cfun = cfun;
   int *entry_flag, *exit_flag;
   unsigned *entry_prob, *exit_prob;
-  unsigned i, num_entry_edges, num_exit_edges;
+  unsigned i, num_entry_edges, num_exit_edges, num_nodes;
   edge e;
   edge_iterator ei;
   htab_t new_label_map;
   struct pointer_map_t *vars_map, *eh_map;
   struct loop *loop = entry_bb->loop_father;
+  struct loop *loop0 = get_loop (saved_cfun, 0);
   struct move_stmt_d d;
 
   /* If ENTRY does not strictly dominate EXIT, this cannot be an SESE
@@ -6760,16 +6761,29 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
   set_loops_for_fn (dest_cfun, loops);
 
   /* Move the outlined loop tree part.  */
+  num_nodes = bbs.length ();
   FOR_EACH_VEC_ELT (bbs, i, bb)
     {
-      if (bb->loop_father->header == bb
-         && loop_outer (bb->loop_father) == loop)
+      if (bb->loop_father->header == bb)
        {
          struct loop *this_loop = bb->loop_father;
-         flow_loop_tree_node_remove (bb->loop_father);
-         flow_loop_tree_node_add (get_loop (dest_cfun, 0), this_loop);
-         fixup_loop_arrays_after_move (saved_cfun, cfun, this_loop);
+         struct loop *outer = loop_outer (this_loop);
+         if (outer == loop
+             /* If the SESE region contains some bbs ending with
+                a noreturn call, those are considered to belong
+                to the outermost loop in saved_cfun, rather than
+                the entry_bb's loop_father.  */
+             || outer == loop0)
+           {
+             if (outer != loop)
+               num_nodes -= this_loop->num_nodes;
+             flow_loop_tree_node_remove (bb->loop_father);
+             flow_loop_tree_node_add (get_loop (dest_cfun, 0), this_loop);
+             fixup_loop_arrays_after_move (saved_cfun, cfun, this_loop);
+           }
        }
+      else if (bb->loop_father == loop0 && loop0 != loop)
+       num_nodes--;
 
       /* Remove loop exits from the outlined region.  */
       if (loops_for_fn (saved_cfun)->exits)
@@ -6789,6 +6803,7 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
 
   /* Setup a mapping to be used by move_block_to_fn.  */
   loop->aux = current_loops->tree_root;
+  loop0->aux = current_loops->tree_root;
 
   pop_cfun ();
 
@@ -6817,11 +6832,13 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
     }
 
   loop->aux = NULL;
+  loop0->aux = NULL;
   /* Loop sizes are no longer correct, fix them up.  */
-  loop->num_nodes -= bbs.length ();
+  loop->num_nodes -= num_nodes;
   for (struct loop *outer = loop_outer (loop);
        outer; outer = loop_outer (outer))
-    outer->num_nodes -= bbs.length ();
+    outer->num_nodes -= num_nodes;
+  loop0->num_nodes -= bbs.length () - num_nodes;
 
   if (saved_cfun->has_simduid_loops || saved_cfun->has_force_vect_loops)
     {