+2012-06-22  Richard Guenther  <rguenther@suse.de>
+
+       Merge from graphite branch
+       2011-08-10  Sebastian Pop <sebpop@gmail.com>
+    
+       * graphite-sese-to-poly.c (build_scop_drs): Fix memory leak.
+
+       2012-01-13  Tobias Grosser  <tobias@grosser.es>
+
+       * tree-flow.h (parallelized_function_p): Declare.
+       * tree-parloops.c (parallelized_function_p): Export.
+       * graphite.c (graphite_transform_loops): Do not run graphite on
+       already parallel functions.
+
 2012-06-22  Alan Modra  <amodra@gmail.com>
 
        * config/rs6000/rs6000.c (rs6000_pre_atomic_barrier): Pass in and
 
     if (VEC_empty (data_reference_p, GBB_DATA_REFS (PBB_BLACK_BOX (pbb))))
       {
        free_gimple_bb (PBB_BLACK_BOX (pbb));
+       free_poly_bb (pbb);
        VEC_ordered_remove (poly_bb_p, SCOP_BBS (scop), i);
        i--;
       }
 
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
 
+  /* If a function is parallel it was most probably already run through graphite
+     once. No need to run again.  */
+  if (parallelized_function_p (cfun->decl))
+    return;
+
   if (!graphite_initialize ())
     return;
 
 
 /* In tree-ssa-ter.c  */
 bool stmt_is_replaceable_p (gimple);
 
+/* In tree-parloops.c  */
+bool parallelized_function_p (tree);
+
 #include "tree-flow-inline.h"
 
 void swap_tree_operands (gimple, tree *, tree *);
 
 
 /* Returns true if FN was created by create_loop_fn.  */
 
-static bool
+bool
 parallelized_function_p (tree fn)
 {
   if (!parallelized_functions || !DECL_ARTIFICIAL (fn))
 
+2012-06-22  Richard Guenther  <rguenther@suse.de>
+
+       Merge from graphite branch
+       2012-01-13  Tobias Grosser  <tobias@grosser.es>
+
+       * testsuite/libgomp.graphite/force-parallel-1.c: Adjust.
+       * testsuite/libgomp.graphite/force-parallel-2.c: Likewise.
+
 2012-06-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/53580
 
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn" 5 "optimized" } } */
 /* { dg-final { cleanup-tree-dump "parloops" } } */
 
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 2 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn" 5 "optimized" } } */
 /* { dg-final { cleanup-tree-dump "parloops" } } */