Allow pass_parallelize_loops to be run outside the loop pipeline
authorTom de Vries <tom@codesourcery.com>
Mon, 18 Jan 2016 12:52:23 +0000 (12:52 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 18 Jan 2016 12:52:23 +0000 (12:52 +0000)
2016-01-18  Tom de Vries  <tom@codesourcery.com>

* tree-parloops.c (pass_parallelize_loops::execute): Allow
pass_parallelize_loops to be run outside the loop pipeline.

From-SVN: r232511

gcc/ChangeLog
gcc/tree-parloops.c

index 8e2b6e6..19a9af1 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-18  Tom de Vries  <tom@codesourcery.com>
+
+       * tree-parloops.c (pass_parallelize_loops::execute): Allow
+       pass_parallelize_loops to be run outside the loop pipeline.
+
 2016-01-18  Alan Lawrence  <alan.lawrence@arm.com>
 
        * tree-scalar-evolution.c (follow_copies_to_constant): New.
index 46d70ac..885103e 100644 (file)
@@ -2844,23 +2844,41 @@ public:
 unsigned
 pass_parallelize_loops::execute (function *fun)
 {
-  if (number_of_loops (fun) <= 1)
-    return 0;
-
   tree nthreads = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS);
   if (nthreads == NULL_TREE)
     return 0;
 
+  bool in_loop_pipeline = scev_initialized_p ();
+  if (!in_loop_pipeline)
+    loop_optimizer_init (LOOPS_NORMAL
+                        | LOOPS_HAVE_RECORDED_EXITS);
+
+  if (number_of_loops (fun) <= 1)
+    return 0;
+
+  if (!in_loop_pipeline)
+    {
+      rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
+      scev_initialize ();
+    }
+
+  unsigned int todo = 0;
   if (parallelize_loops ())
     {
       fun->curr_properties &= ~(PROP_gimple_eomp);
 
       checking_verify_loop_structure ();
 
-      return TODO_update_ssa;
+      todo |= TODO_update_ssa;
+    }
+
+  if (!in_loop_pipeline)
+    {
+      scev_finalize ();
+      loop_optimizer_finalize ();
     }
 
-  return 0;
+  return todo;
 }
 
 } // anon namespace